Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement DOMParser interface #137

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

penguinput
Copy link

@penguinput penguinput commented Dec 25, 2018

This implementation seems to work correctly when the content type is set
to text/html, however the XML types fall through the HTMLParser since
there's no XMLSerializer interface.

The tests for the text/html type are passing, except the baseURI one, since its getter is not yet implemented in the lib/Node.js file.
If, in the future, the XMLSerializer interface is implemented I think it should be easy to add the missing logic.

Lastly: I'm not sure if the DOMParser interface should be exposed the way I did.
It needs to access the active document address and I didn't find any other way to make it work.
Maybe, by logic, it should go into the lib/impl.js file?


Edit:

At the end I decided to definitely throw on the not-yet-implemented XML types to avoid misleading behavior with the HTMLParser fallback (case sensitivity to name one).
Still, I'm not really sure I exposed the DOMParser interface the proper way.

This implements the DOMParser interface.
As of now, only the "text/html" type is supported, the unsupported types
will throw.
@penguinput penguinput changed the title Add DOMParser interface (WIP) Implement DOMParser interface Dec 28, 2018
@@ -4,6 +4,7 @@ var EventTarget = require('./EventTarget');
var Location = require('./Location');
var sloppy = require('./sloppy');
var utils = require('./utils');
var DOMParserWrapper = require("./DOMParser");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this DOMParserWrapper and not just DOMParser? None of the other classes have ...Wrapper suffixes.

@@ -3036,6 +3035,9 @@
"dom/nodes/Element-siblingElement-null-xhtml.xhtml": [
"Uncaught: Unexpected token <"
],
"dom/nodes/Element-tagName.html": [
"tagName should be updated when changing ownerDocument"
],
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a new test failure. Why?

"Location value",
"DOMParser parses HTML tag soup with no problems",
"DOMParser throws on an invalid enum value"
"baseURI value"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice that we pass these tests now!

@@ -12,6 +13,7 @@ function Window(document) {
this.document._scripting_enabled = true;
this.document.defaultView = this;
this.location = new Location(this, this.document._address || 'about:blank');
this.DOMParser = DOMParserWrapper(this);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, this isn't the right way to export it. You should instead add this to lib/impl.js, which then gets merged into Window in via utils.expose in the last line of this file.

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.

2 participants