-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Implement DOMNode::isConnected and DOMNameSpaceNode::isConnected #11677
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
Conversation
Note: Test failures are related to recent ext/date changes, unrelated to this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks sensible to me, other the minor thing that requires some clarification.
@theseer do you want to verify the test output?
/** @readonly */ | ||
public bool $isConnected; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is a new property, I think you can just use the normal keyword. @kocsismate is my assumption correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, absolutely, if the implementation is in line with readonly
! :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this is more like a calculated field than a real readonly property (the value can change multiple times even though it's not possible to write by users), so the @readonly
is correct here!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Máté, for clarifying!
/** @readonly */ | ||
public bool $isConnected; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
I can only give feedback on the added testcase The behavior outlined in the new ext/dom/tests/DOMNode_DOMNameSpaceNode_isConnected.phpt though is what I would have expected and seems according to the standard as I understand it. I do have a question though: I'm not fully convinced that My reasoning: As it's the document itself, I'd say it logically cannot be connected to anything. The "highest" level I'd expect to be connectable (if that's a word) would be |
Thx for having a look.
From https://dom.spec.whatwg.org/#connected:
And from https://dom.spec.whatwg.org/#concept-tree-root:
Since document's parent is null, the root it itself. Therefore, isConnected must be true. |
So I indeed missed that. Thanks for the clarification, @nielsdos :) |
ref: https://dom.spec.whatwg.org/#dom-node-isconnected