Skip to content

locator isn't true by default when using any other options #802

Description

@Ponynjaa

Describe the bug
When providing options to the DOMParser constructor and leaving out the locator option this option will not be set to true even though the typedef says it is true by default.

It is only being set to true here when the options are omitted completely.

To Reproduce

import * as xmldom from '@xmldom/xmldom';

const parser = new xmldom.DOMParser({
	onError: (level, message) => {
		console.log({level, message});
	}
});

try {
	const doc = parser.parseFromString(`<?xml version="1.0" encoding="utf-8"?>
		<content>
			<chapter>
		</content>
	`, 'text/xml');
} catch (error) {
	console.log(error.locator); // -> undefined
}

Expected behavior
In the example above error.locator should be { lineNumber: 3, columnNumber: 13 }.

Runtime & Version:
xmldom version: 0.9.2
runtime version: Node 20

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds investigationInformation is missing and needs to be researched

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions