-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Implement DOMElement::insertAdjacent{Element,Text} #11700
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
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.
I didn't really have a look at the test cases. @theseer do you want to double check?
php_dom_throw_error(SYNTAX_ERR, dom_get_strict_error(this_intern->document)); | ||
return INSERT_ADJACENT_RES_FAILED; |
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.
The spec seem to indicate that a DOMException must be thrown:
php_dom_throw_error(SYNTAX_ERR, dom_get_strict_error(this_intern->document)); | |
return INSERT_ADJACENT_RES_FAILED; | |
php_dom_throw_error(SYNTAX_ERR, true); | |
return INSERT_ADJACENT_RES_FAILED; |
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, but strangely PHP offers an "stricterror" option (default true) which allows you to get warnings instead of exceptions.
And that maybe doesn't even violate spec, because from https://webidl.spec.whatwg.org/#dfn-throw
The resulting behavior from creating and throwing an exception is language binding specific.
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.
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.
Yeah PHP extension used to have the trifecto of no warning/exception, warnings, exceptions. I think mainly because prior to the introduction of exception warnings were the only way.
We probably should get rid of those and only allow silent or exception behaviour (similarly to the SQLite3 RFC) but that's future scope
The existing tests look good to me. Two questions:
|
Thanks for having a look.
Not sure what that means to be honest. It seems Firefox specific. Spec doesn't define it so I'd say we should ignore this.
Good point, I'll add a small test for this. |
0eb2350
to
8019499
Compare
ref: https://dom.spec.whatwg.org/#dom-element-insertadjacentelement
ref: https://dom.spec.whatwg.org/#dom-element-insertadjacenttext