Skip to content

Conversation

@doug-jacob
Copy link
Contributor

Closes #34

The MDN Web API for DOM parsing is now supported with the addition of xmldom:
https://github.com/xmldom/xmldom

Users can now parse and edit XML documents:

const dp = new DOMParser();
const xmlDoc = dp.parseFromString("<p>some text</p>", "text/xml");
const firstElement = xmlDoc.firstChild;
const newElement = xmlDoc.createElement("span");
newElement.textContent = "some new text";
firstElement.appendChild(newElement);
const xs = new XMLSerializer();
const output = xs.serializeToString(xmlDoc);

// expected output: <p>some text<span>some new text</span></p>
console.log(output);

…om files are always copied to the output directory; made xmldom be loaded in EngineWrapper startup
@doug-jacob doug-jacob requested a review from oconnor0 February 10, 2025 18:45
@doug-jacob doug-jacob marked this pull request as draft February 10, 2025 18:51
…or loading JS libraries in EngineWrapper; added test to cover xmldom
@doug-jacob doug-jacob marked this pull request as ready for review February 10, 2025 21:16
Copy link
Contributor

@oconnor0 oconnor0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Just needs a bit of documentation.

Not exactly sure I can meaningfully review Vender/xmldom, but then I don't fully review other third-party deps.

return result;
}

internal void LoadJsLibrary(string fullFilePath, DocumentCategory category) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may need to become a more formal thing at some point to support IPlugin but is great for now.

@oconnor0 oconnor0 merged commit d63c26d into master Feb 10, 2025
1 check passed
@oconnor0 oconnor0 deleted the adding-xml-support branch February 10, 2025 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend API support with XML

3 participants