Skip to content

Make Attr extend Node#2770

Merged
domenic merged 21 commits intojsdom:masterfrom
ExE-Boss:fix/make-attr-extend-node
Jan 25, 2020
Merged

Make Attr extend Node#2770
domenic merged 21 commits intojsdom:masterfrom
ExE-Boss:fix/make-attr-extend-node

Conversation

@ExE-Boss
Copy link
Contributor

@ExE-Boss ExE-Boss commented Jan 2, 2020

Resolves #1641
Supersedes and closes #1822

@ExE-Boss ExE-Boss force-pushed the fix/make-attr-extend-node branch from 28edf1a to 8075537 Compare January 2, 2020 00:40
@ExE-Boss
Copy link
Contributor Author

ExE-Boss commented Jan 2, 2020

Looks like there’s some weird circular dependency issues.

One way to fix it would be to change WebIDL2JS to generate exports.* = assignments, rather than module.exports = iface;.

@domenic
Copy link
Member

domenic commented Jan 2, 2020

Oh, awesome.

Note that the spec changes for this were pretty involved. I'm unsure what that translates to in terms of jsdom changes, exactly, but we should probably at least pass any of the web platform tests that got updated.... although it looks like maybe the spec changed before we had a tests-required policy in WHATWG :-/.

@domenic
Copy link
Member

domenic commented Jan 2, 2020

Looks like there’s some weird circular dependency issues.

Are they the same issues as #1247 (comment) ?

Could we merge attributes.js and Attr-impl.js to fix them?

@ExE-Boss
Copy link
Contributor Author

ExE-Boss commented Jan 2, 2020

Could we merge attributes.js and Attr-impl.js to fix them?

I’d rather fix WebIDL2JS to generate code that doesn’t completely break on circular require(…)s by creating properties on exports, rather than re‑assigning it: jsdom/webidl2js#154.

@domenic
Copy link
Member

domenic commented Jan 2, 2020

I'd rather avoid the circular requires; they're a sign of bad architecture, and I'm not willing to change our tools to make them easier.

@ExE-Boss ExE-Boss force-pushed the fix/make-attr-extend-node branch from 0f411ab to 1987d33 Compare January 2, 2020 13:10
@ExE-Boss ExE-Boss force-pushed the fix/make-attr-extend-node branch from 1987d33 to a852742 Compare January 4, 2020 01:38
@ExE-Boss ExE-Boss force-pushed the fix/make-attr-extend-node branch from 341f636 to e07359e Compare January 4, 2020 15:26
@ExE-Boss
Copy link
Contributor Author

ExE-Boss commented Jan 4, 2020

review?(@domenic): The tests are now passing.

@domenic
Copy link
Member

domenic commented Jan 4, 2020

As stated previously I want us to remove the circular dependency before making any changes in this area.

@ExE-Boss
Copy link
Contributor Author

ExE-Boss commented Jan 4, 2020

That will just create another circular dependency, this time between NodeImpl and AttrImpl.

This is because attributes.js is also required by Node‑impl.js:

const attributes = require("../attributes");

Since the methods and properties inherited from Node branch on the node type.

@domenic
Copy link
Member

domenic commented Jan 4, 2020

It seems very doable, you just have to not keep all the functions together. E.g. move attributeListsEquals and setAnExistingAttributeValue into Node-impl.js.

@ExE-Boss
Copy link
Contributor Author

ExE-Boss commented Jan 5, 2020

setAnExistingAttributeValue(…) transiently depends on changeAttribute(…), the latter of which is depended upon by ElementImpl, setAttributeValue(…) and possibly other places, this means that I have to re‑export changeAttribute(…) from attributes.js.

@ExE-Boss ExE-Boss force-pushed the fix/make-attr-extend-node branch from 4e36c8a to d9570ad Compare January 5, 2020 03:32
@domenic
Copy link
Member

domenic commented Jan 7, 2020

This is looking pretty good. Do you have any thoughts on the compareDocumentPosition changes I linked to?

@ExE-Boss
Copy link
Contributor Author

ExE-Boss commented Jan 7, 2020

@domenic Where can I find the compareDocumentPosition(…) changes you mentioned?

@domenic
Copy link
Member

domenic commented Jan 7, 2020

The three commits linked in #2770 (comment)

@domenic
Copy link
Member

domenic commented Jan 18, 2020

Ping; any thoughts about compareDocumentPosition()? Do you think we should merge this and work on that later?

@ExE-Boss ExE-Boss requested review from domenic and pmdartus January 18, 2020 23:38
@ExE-Boss
Copy link
Contributor Author

In fact, using madge to measure dependency cycles, I’ve determined that moving copyAttributeList to living/node.js increases the number of circular dependencies from 9 to 10.

@domenic
Copy link
Member

domenic commented Jan 23, 2020

I am confident that the circular dependencies can be detangled. If you cannot do it, that just means we'll have to wait on someone who can.

@ExE-Boss
Copy link
Contributor Author

ExE-Boss commented Jan 23, 2020

I’ve managed to get the number of circular dependencies down by 1, when compared to master, by removing the following one, as reported by madge:

  1. jsdom/living/generated/Attr.js > jsdom/living/attributes/Attr-impl.js > jsdom/living/attributes.js

I did it by exposing _createAttribute on DocumentImpl, which doesn’t apply strict XML validation on the attribute name, which allowed me to use the existing Document‑based workaround used inside clone.

@ExE-Boss ExE-Boss requested a review from domenic January 23, 2020 18:43
@ExE-Boss ExE-Boss requested review from TimothyGu and domenic and removed request for domenic January 23, 2020 23:31
Copy link
Member

@TimothyGu TimothyGu left a comment

Choose a reason for hiding this comment

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

Almost there, but with some final issues. Also please revert the last bits of export style changes. Happy to see that we can continue using attributes.js!

Co-Authored-By: Timothy Gu <timothygu99@gmail.com>
@ExE-Boss ExE-Boss force-pushed the fix/make-attr-extend-node branch 2 times, most recently from d3117c2 to 7bdecbb Compare January 24, 2020 17:40
ExE-Boss and others added 2 commits January 24, 2020 18:41
`Element‑impl.js` is no longer affected by this PR,
so this reverts `exports` changes made to it.

Co-Authored-By: Timothy Gu <timothygu99@gmail.com>
Co-Authored-By: Timothy Gu <timothygu99@gmail.com>
@ExE-Boss ExE-Boss force-pushed the fix/make-attr-extend-node branch from e07b2f5 to 2af3a32 Compare January 25, 2020 11:25
Co-Authored-By: Timothy Gu <timothygu99@gmail.com>
@ExE-Boss ExE-Boss requested a review from TimothyGu January 25, 2020 11:48
@domenic domenic merged commit b8c7bb5 into jsdom:master Jan 25, 2020
@domenic domenic deleted the fix/make-attr-extend-node branch January 25, 2020 22:51
@domenic
Copy link
Member

domenic commented Jan 25, 2020

Regardless of my frustration about the process of working with you on this, I do want to say thank you for taking it on, and that I am happy with the end result. It's a pretty good improvement that solves a ~3 year old bug report.

Thanks as well to @TimothyGu for stepping in when I was burning out on the process.

@TimothyGu TimothyGu mentioned this pull request Feb 2, 2020
@ExE-Boss ExE-Boss changed the title fix: Make Attr extend Node Make Attr extend Node Mar 25, 2021
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