-
-
Notifications
You must be signed in to change notification settings - Fork 236
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
Align Attribute interface names with Attr from the DOM #287
Comments
I recall discussing similar topic with @domenic some time ago. This puts me in a bit complicated situation: even though from spec perspective it's correct to use such terms as |
I'm not sure how many "casual parse5 users" there are :). Probably folks should be able to understand the DOM tree concepts... |
npm counts 605 dependants currently. I'm quite convinced that the vast majority of them will be confused by |
Maybe you could add the proper terms for folks who know what they refer to, and add alias getters for folks who don't want to read the docs/DOM standard? Right now, for those of us who are aware of the difference between tagName, localName, and qualifiedName, the usage of name and tagName are confusing. |
Yes, that could be an acceptable solution. |
Just came across this while trying to find a DOM structure that works with both I ended up using the
Any suggestions for how I can fix these interop issues? |
For anyone still interested in getting xpath selection working with parse5, here's the gist ✨ https://gist.github.com/mattfysh/92e160e5f2a4cf7d569f3c2bf012c217 I've run the xpath test suite and half the tests work, the other half are failing (mostly relating to namespaces, which don't make much of an appearance on the web). So far things are working well, and hopefully if any unsupported use cases come up they can be addressed by adding more DOM-like features to @inikulin @domenic @Zirro - I'm keen to hear your thoughts 🙏 |
The Attribute interface has four properties named
name
,namespace
,prefix
andvalue
. Three of these share their names with the Attr interface of the DOM. However, therenamespace
is namednamespaceURI
and the expected value of thename
property is actually consistent withlocalName
rather thanname
in the DOM.It turns out that this has been a source of minor bugs in jsdom. Our adapter for
getAttrList()
has been returning aNamedNodeMap
with DOM attributes inside. Since the interface is expecting a property namednamespace
rather thannamespaceURI
, our HTML serialization has not included namespaces. If we resolve this by changing the property name, it reveals the other problem with the difference betweenname
andlocalName
sincename
in the DOM is defined as the full qualified name.To reduce the confusion, I'd like to suggest a breaking change to align the properties of parse5's Attribute interface with the ones from the DOM (as well as make it consistent with parse5's Element interface which also uses
namespaceURI
), so thatnamespace
becomesnamespaceURI
andname
becomeslocalName
. Since the HTML parsing/serialization specification also refers to "local name" it could help make things clearer in several ways.It would also avoid the potentially slow operation of renaming properties before passing them to parse5 in jsdom and other consumers with a DOM-based structure.
Potentially related: #231
The text was updated successfully, but these errors were encountered: