Intent to Implement and Ship: ChildNode.before() API

216 views
Skip to first unread message

Paritosh Kumar

unread,
Apr 14, 2015, 8:35:44 AM4/14/15
to blin...@chromium.org, tk...@chromium.org

Contact emails

parit...@samsung.com


Spec

https://dom.spec.whatwg.org/#dom-childnode-before


Summary

Add ChildNode.before() API.


Motivation

This will allow a web developer to insert a set of Node or DOMString objects in the children list of this ChildNode's parent, just before this ChildNode.
DOMString objects are inserted as equivalent Text nodes.  We can use Node.insertBefore() but it can be used for single node only. No direct way for 

inserting a set of children.


Compatibility Risk

Low, As other browsers are also implementing it.




Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?

Yes.


OWP launch tracking bug?

None.

Rick Byers

unread,
Apr 14, 2015, 8:54:14 AM4/14/15
to Paritosh Kumar, blink-dev, Kent Tamura
What's the status in the other browsers exactly?

Paritosh Kumar

unread,
Apr 14, 2015, 9:09:45 AM4/14/15
to blin...@chromium.org, parit...@samsung.com, tk...@chromium.org
FireFox: Not Supported
Safari: Not Supported
IE: Not Supported

Rick Byers

unread,
Apr 14, 2015, 9:15:24 AM4/14/15
to Paritosh Kumar, blink-dev, Kent Tamura
On Tue, Apr 14, 2015 at 9:09 AM, Paritosh Kumar <parit...@samsung.com> wrote:
FireFox: Not Supported
Safari: Not Supported
IE: Not Supported

Your compatibility risk section said other browsers were implementing it?  Are there public signals of support somewhere?

Paritosh Kumar

unread,
Apr 14, 2015, 9:25:50 AM4/14/15
to blin...@chromium.org, parit...@samsung.com, tk...@chromium.org

Boris Zbarsky

unread,
Apr 14, 2015, 9:31:22 AM4/14/15
to blink-dev
On 4/14/15 9:14 AM, Rick Byers wrote:
> On Tue, Apr 14, 2015 at 9:09 AM, Paritosh Kumar <parit...@samsung.com
> <mailto:parit...@samsung.com>> wrote:
>
> FireFox: Not Supported

The general status for Firefox is that we do not implement it, we have
no specific plans to implement it yet, and we are not likely to
implement it before we have support for @@unscopables in SpiderMonkey,
for which there is no current ETA because it's lower priority than other
JS engine work (e.g. classes). See
https://bugzilla.mozilla.org/show_bug.cgi?id=911477

Furthermore, we haven't really taken a look at the spec as it stands to
see whether it makes sense as something to implement, though we could do
that if it would be helpful.

-Boris

stepien...@gmail.com

unread,
Apr 14, 2015, 1:03:49 PM4/14/15
to blin...@chromium.org, tk...@chromium.org

Elliott Sprehn

unread,
Apr 14, 2015, 1:54:09 PM4/14/15
to Paritosh Kumar, blink-dev, Kent Tamura

On Tue, Apr 14, 2015 at 5:35 AM, Paritosh Kumar <parit...@samsung.com> wrote:

...


Motivation

This will allow a web developer to insert a set of Node or DOMString objects in the children list of this ChildNode's parent, just before this ChildNode.
DOMString objects are inserted as equivalent Text nodes.  We can use Node.insertBefore() but it can be used for single node only. No direct way for 

inserting a set of children.


This is the same as insertBefore with a document fragment, the only magic is the conversion from strings to Text nodes. That's how the spec describes it too. :)

- E

Philip Jägenstedt

unread,
Apr 14, 2015, 2:10:30 PM4/14/15
to Paritosh Kumar, Alex Russell, blink-dev, Kent Tamura
Hi Paritosh,

We discussed this in today's API owners meeting and have some feedback.

First, ChildNode.before((Node or DOMString)... nodes) is one in a
group of new DOM convenience APIs that would make sense to implement
as a group, the others being:
ChildNode.after((Node or DOMString)... nodes)
ChildNode.replaceWith((Node or DOMString)... nodes)
ParentNode.prepend((Node or DOMString)... nodes)
ParentNode.append((Node or DOMString)... nodes)

All of these have [Unscopeable] in the IDL and since support for that
seems to be on the near horizon it seems safest to wait for a little
bit. If it turns out that [Unscopeable] isn't going to be done any
time soon we'll have to re-evaluate. (ChildNode.remove() is already
shipping without [Unscopeable].)

So in summary, LGTM to implement
ChildNode.before()/after()/replaceWith() and
ParentNode.prepend()/append().

Before shipping, we'd like to run this through TAG review, as a fairly
simple test of that whole process. Alex is preparing a template to
request that review.

Philip
> To unsubscribe from this group and stop receiving emails from it, send an
> email to blink-dev+...@chromium.org.

Philip Jägenstedt

unread,
Apr 15, 2015, 3:59:18 AM4/15/15
to Paritosh Kumar, Alex Russell, blink-dev, Kent Tamura
Dimitri pointed out that ES6 Unscopeables are already supported:
https://www.chromestatus.com/features/4543115071324160

That means that only the bindings bit is missing:
https://code.google.com/p/chromium/issues/detail?id=462916

Philip

stepien...@gmail.com

unread,
Apr 27, 2015, 2:20:05 PM4/27/15
to blin...@chromium.org, sligh...@google.com, tk...@chromium.org, parit...@samsung.com

Paritosh Kumar Monu

unread,
May 6, 2015, 1:29:43 AM5/6/15
to blin...@chromium.org, stepien...@gmail.com, parit...@samsung.com, tk...@chromium.org, sligh...@google.com
Thanks


As per Philip's  suggestion, We are implementing new DOM convenience APIs
i.e.
     ChildNode.before((Node or DOMString)... nodes) 
     ChildNode.after((Node or DOMString)... nodes)
     ChildNode.replaceWith((Node or DOMString)... nodes)
     ParentNode.prepend((Node or DOMString)... nodes)
     ParentNode.append((Node or DOMString)... nodes)

in a group, with a RunTime Flag.

As Unscopeable is supported, we will use Unscopeable for all these apis.


-Paritosh

Sigbjorn Finne

unread,
May 3, 2016, 7:34:56 AM5/3/16
to blin...@chromium.org, Paritosh Kumar Monu, stepien...@gmail.com, tk...@chromium.org, sligh...@google.com

This addition has now landed ( https://crrev.com/391196 ) as an
experimental feature, it unfortunately dropping off our collective radar
during the initial attempt.

Once we're satisfied that it has nestled in well, shipping is well worth
considering, see https://crbug.com/255482 for updated compat info. If
anyone wants to drive that, feel free to grab the wheel/handlebars.

--sigbjorn

Elliott Sprehn

unread,
May 3, 2016, 1:54:31 PM5/3/16
to Sigbjorn Finne, blink-dev, Kent TAMURA, stepien...@gmail.com, Paritosh Kumar Monu, sligh...@google.com

Do any other browsers have this yet?

Sigbjorn Finne

unread,
May 3, 2016, 2:17:09 PM5/3/16
to Elliott Sprehn, blink-dev, Kent TAMURA, stepien...@gmail.com, Paritosh Kumar Monu, sligh...@google.com
Den 5/3/2016 19:54, Elliott Sprehn skreiv:
> Do any other browsers have this yet?

Safari (July 2015) and Firefox nightlies; see 255482 for bug references.

--sigbjorn

PhistucK

unread,
May 3, 2016, 2:19:49 PM5/3/16
to Sigbjorn Finne, Elliott Sprehn, blink-dev, Kent TAMURA, Nicolas Stepien, Paritosh Kumar Monu, Alex Russell
Is this only discussing before(), or the other methods as well?
For the latter, you better post a new intent (and include the information in it instead of pointing to bugs, please, please, please :)).


PhistucK

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.

Sigbjorn Finne

unread,
May 3, 2016, 2:24:49 PM5/3/16
to PhistucK, Elliott Sprehn, blink-dev, Kent TAMURA, Nicolas Stepien, Paritosh Kumar Monu, Alex Russell
Den 5/3/2016 20:19, PhistucK skreiv:
> Is this only discussing before(), or the other methods as well?
> For the latter, you better post a new intent (and include the information
> in it instead of pointing to bugs, please, please, please :)).
>

The ChildNode + ParentNode additions all go together (see what landed
for a list + this intent-to-I&S thread); it's too early for an intent to
ship, imho.

--sigbjorn
Reply all
Reply to author
Forward
0 new messages