Bug 19962 - Add insertAdjacentText and insertAdjacentElement?
Summary: Add insertAdjacentText and insertAdjacentElement?
Status: NEW
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: DOM (show other bugs)
Version: unspecified
Hardware: PC Windows 3.1
: P2 normal
Target Milestone: ---
Assignee: Anne
QA Contact: public-webapps-bugzilla
URL:
Whiteboard: blocked on implementers weighing in
Keywords:
Depends on:
Blocks:
 
Reported: 2012-11-14 14:14 UTC by Anne
Modified: 2015-01-20 13:05 UTC (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Comment 1 Anne 2012-11-14 14:26:51 UTC
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).
Comment 2 Simon Pieters 2012-11-14 15:11:43 UTC
$ grep -aPc "\.insertAdjacentElement\s*\(" web200904 
85
$ grep -aPc "\.insertAdjacentText\s*\(" web200904 
4
$ grep -aPc "\.insertAdjacent(Text|Element)\s*\(" stevef-all
0
Comment 3 Simon Pieters 2012-11-14 15:20:08 UTC
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
Comment 5 Anne 2013-09-06 15:08:27 UTC
This now depends on http://code.google.com/p/chromium/issues/detail?id=286321
Comment 6 Ojan Vafai 2014-02-04 18:16:52 UTC
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.
Comment 7 Anne 2014-02-13 11:52:16 UTC
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().
Comment 8 Philip Jägenstedt 2014-12-19 23:43:35 UTC
Is DOM still the right spec for this, given https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#insertadjacenthtml() ?
Comment 9 Anne 2014-12-20 10:02:49 UTC
Yeah, these methods don't involve any parsing. Same situation as with isSameNode() though.
Comment 10 Philip Jägenstedt 2014-12-21 01:02:10 UTC
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.
Comment 11 Anne 2014-12-21 18:44:49 UTC
That only makes sense if we decide to standardize these two methods.
Comment 12 Philip Jägenstedt 2015-01-20 13:05:24 UTC
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.