You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It cannot use "insert" directly. That should probably be "pre-insert". And now I introduced "insert adjacent" it should probably reuse that: whatwg/dom@8fa7ac7.
"insert adjacent" doesn't fit here because insertAdjacentHTML() for "beforebegin" and "afterend" throw "NoModificationAllowedError" when context doesn't have parent (Firefox/Chrome/IE11 do this but not Presto).
For insertAdjacentText() and insertAdjacentElement() and the same position whe have:
Chrome/Firefox return null for insertAdjacentElement()
IE11 throw for insertAdjacentText() but not for insertAdjacentElement() and return passing element.
Presto throw for insertAdjacentElement() but not for insertAdjacentText() and return undefined.
Edge:...
I will update tests in WPT to check this cases.
Right, probably work, just changing step 4. to use "insert adjacent", parent will be checking earlier.
@annevk But looks like actual definition is correct, owner for new nodes is setting in fragment parsing algorithm and this method is not flexible like insertBefore(), so never operate on element as context object where parent is Document (because throw), validate from "pre-insert" is unnecessary (other cases, like for Doctype will be catching by XML parser and throw SyntaxError or ignore by HTML parser). Even for "beforeend" P&S can replace "append" by "insert": "Insert fragment into the context object before null" and in all cases we will have "insert". But may be I wrong...
Activity
ArkadiuszMichalski commentedon May 4, 2016
"insert adjacent" doesn't fit here because
insertAdjacentHTML()for"beforebegin"and"afterend"throw"NoModificationAllowedError"when context doesn't have parent (Firefox/Chrome/IE11 do this but not Presto).For
insertAdjacentText()andinsertAdjacentElement()and the same position whe have:Chrome/Firefox return null for
insertAdjacentElement()IE11 throw for
insertAdjacentText()but not forinsertAdjacentElement()and return passing element.Presto throw for
insertAdjacentElement()but not forinsertAdjacentText()and return undefined.Edge:...
I will update tests in WPT to check this cases.
annevk commentedon May 4, 2016
Hmm, https://code.google.com/p/chromium/codesearch#chromium/src/third_party/WebKit/Source/core/dom/Element.cpp&q=insertadjacenthtml&sq=package:chromium&type=cs&l=2654 does show that some amount of code is shared. There might be an additional check needed though.
ArkadiuszMichalski commentedon May 4, 2016
Right, probably work, just changing step 4. to use "insert adjacent", parent will be checking earlier.
@annevk But looks like actual definition is correct, owner for new nodes is setting in fragment parsing algorithm and this method is not flexible like
insertBefore(), so never operate on element as context object where parent isDocument(because throw), validate from "pre-insert" is unnecessary (other cases, like for Doctype will be catching by XML parser and throwSyntaxErroror ignore by HTML parser). Even for"beforeend"P&S can replace "append" by "insert": "Insert fragment into the context object before null" and in all cases we will have "insert". But may be I wrong...