This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
https://bugzilla.mozilla.org/show_bug.cgi?id=811259 suggests they might be quite widely supported. Have not verified. Compared to before()/after()/prepend()/append() they kinda suck. http://msdn.microsoft.com/en-us/library/ms536451(v=vs.85).aspx http://msdn.microsoft.com/en-us/library/ms536453%28v=vs.85%29.aspx http://domparsing.spec.whatwg.org/#dom-element-insertadjacenthtml
Support: Opera/Chrome/Safari and presumably Internet Explorer. Opera/Chrome/Safari expose them on Element, not Document or Text, and probably none of the other node types either (did not test).
$ grep -aPc "\.insertAdjacentElement\s*\(" web200904 85 $ grep -aPc "\.insertAdjacentText\s*\(" web200904 4 $ grep -aPc "\.insertAdjacent(Text|Element)\s*\(" stevef-all 0
Those data sets are http://dotnetdotcom.org/ and http://www.paciellogroup.com/blog/2012/04/html5-accessibility-chops-data-for-the-masses/ respectively. For comparison purposes: $ grep -aPc "\.insertAdjacentHTML\s*\(" web200904 602 $ grep -aPc "\.insertAdjacentHTML\s*\(" stevef-all 5
Those data sets do not have external scripts. Checking with google code search: External scripts: http://code.google.com/codesearch#search/&q=%5C.insertAdjacentElement%5Cs*%5C(%20lang:js&type=cs 1,292 http://code.google.com/codesearch#search/&q=%5C.insertAdjacentText%5Cs*%5C(%20lang:js&type=cs 24 http://code.google.com/codesearch#search/&q=%5C.insertAdjacentHTML%5Cs*%5C(%20lang:js&type=cs 1,667 Internal scripts: http://code.google.com/codesearch#search/&q=%5C.insertAdjacentElement%5Cs*%5C(%20lang:html&type=cs 109 http://code.google.com/codesearch#search/&q=%5C.insertAdjacentText%5Cs*%5C(%20lang:html&type=cs 6 http://code.google.com/codesearch#search/&q=%5C.insertAdjacentHTML%5Cs*%5C(%20lang:html&type=cs 259
This now depends on http://code.google.com/p/chromium/issues/detail?id=286321
Chrome's measurements: insertAdjacentElement: 0.036% of pageviews insertAdjacentText: 0.00034% of pageviews insertAdjacentElement is likely too high of usage for us to be able to safely remove it. Given that we're stuck with insertAdjacentHTML and insertAdjacentElement, I don't see the benefit of removing just insertAdjacentText.
Given https://bugzilla.mozilla.org/show_bug.cgi?id=199191#c15 maybe it's reasonable to add this cruft after all. It's kind of sad given before() / after().
Is DOM still the right spec for this, given https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#insertadjacenthtml() ?
Yeah, these methods don't involve any parsing. Same situation as with isSameNode() though.
Could the common bits between insertAdjacentHTML(), insertAdjacentElement() and insertAdjacentText() be pulled into DOM then? In Blink there's a common insertAdjacent() internally which take a Node, and the Web-exposed functions do very little on top of that.
That only makes sense if we decide to standardize these two methods.
I say let's standardize insertAdjacentText and insertAdjacentElement. They don't add any real complexity on top of insertAdjacentHTML and at least insertAdjacentElement is used enough that removal wouldn't be painless.
I think we could add those to the spec.
https://github.com/whatwg/dom/commit/8fa7ac749d1b612504184aad2c20808a1785b370 Thanks all.
Tests requested in https://github.com/w3c/web-platform-tests/issues/2672