[Bug 15611] [Shadow]: Consider element.createShadowRoot as API for creating ShadowRoot objects.

https://www.w3.org/Bugs/Public/show_bug.cgi?id=15611

--- Comment #2 from Elliott Sprehn <esprehn@gmail.com> ---
(In reply to comment #1)
> ...
> This is new. I'll repurpose the bug to track this. So far, my thinking is
> that "new ShadowRoot(..)" is shorter, and doesn't require extending
> HTMLElement API surface.

We're already extending the API surface with public shadows, and having a
constructor that has side effects is very weird. I can't think of any other
place in the platform where constructing an object has side effects like this
(and it's usually considered a code smell).

It's particularly weird in the implementation of WebKit as we call
ShadowRoot::create(this) often and discard the return value which is
non-obvious to someone looking at the code. Once we expose public shadows
people may do the same thing:

function doSomething() {
  // Not obvious this does anything.
  new ShadowRoot(element);
}

element.oldestShadowRoot.appendChild(...);

so I'd propose addShadowRoot() which is the same number of characters and
models what's going on better.

element.addShadowRoot()

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Friday, 2 November 2012 20:42:13 UTC