Skip to content

Make Attr extend Node again#1822

Closed
Robbert wants to merge 13 commits intojsdom:masterfrom
Robbert:attr-extends-node
Closed

Make Attr extend Node again#1822
Robbert wants to merge 13 commits intojsdom:masterfrom
Robbert:attr-extends-node

Conversation

@Robbert
Copy link
Copy Markdown

@Robbert Robbert commented Apr 26, 2017

This is my proposal for the approach to fix #1641 by extending Attr from Node again, so attr.nodeType exists again etcetera. snuggs requested to send a pull request so it would be easier to review my changes and judge the approach.

I am aware that several unit tests are now failing, and I plan to spend time on fixing those when the general idea of this fix is okay with you all.

Copy link
Copy Markdown
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

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

I don't understand the reason behind this whole generic node-building/testing framework. It should be simply a matter of updating the Web IDL to do : Node, updating the impl to do extends NodeImpl, and then a few other minor tweaks.


NamedNodeMap.prototype.setNamedItem = function (attr) {
if (!attrGenerated.is(attr)) {
if (!this[INTERNAL].element._ownerDocument._isNodeType(attr, NODE_TYPE.ATTRIBUTE_NODE)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why this change? The old code should still work.

const attribute = exports.getAttributeByNameNS(element, namespace, localName);
if (attribute === null) {
const newAttribute = attrGenerated.createImpl([], { namespace, namespacePrefix: prefix, localName, value });
const newAttribute = element._ownerDocument._createNode(NODE_TYPE.ATTRIBUTE_NODE, [], {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Again, the old code should still work here. There's no advantage to using _createNode (here and below).

@Robbert
Copy link
Copy Markdown
Author

Robbert commented Apr 29, 2017

The reason was the whole cyclic-dependency problem you also ran into earlier:

@domenic
Copy link
Copy Markdown
Member

domenic commented Apr 29, 2017

Oh, I see :(. OK, let me reconsider...

@TimothyGu
Copy link
Copy Markdown
Member

The circular dependency problem should be gone after #2052.

@snuggs
Copy link
Copy Markdown
Contributor

snuggs commented Jan 4, 2018

@TimothyGu thanks a bunch with the info on #2052 . That should help out with #1641

@Robbert what do we do next to move forward on this?

@ExE-Boss ExE-Boss mentioned this pull request Jan 2, 2020
domenic pushed a commit that referenced this pull request Jan 25, 2020
Fixes #1641. Closes #1822 by superseding it.
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.

Make Attr inherit from Node again

4 participants