[webcomponents] [Custom]: Need to define global/Realm handling for registerElement (bugzilla: 27260) (#185)

Title: [Custom]: Need to define global/Realm handling for registerElement (bugzilla: 27260)

Migrated from: https://www.w3.org/Bugs/Public/show_bug.cgi?id=27260

----
comment: 0
comment_url: https://www.w3.org/Bugs/Public/show_bug.cgi?id=27260#c0
*Boris Zbarsky* wrote on 2014-11-06 17:18:44 +0000.

Created attachment 1535
Testcase

Consider this testcase:

  \<iframe\>\</iframe\>
  \<script\>
    var f = document.registerElement.call(frames[0].document, "x-foo");
  \</script\>

Per the spec, this should "let PROTOTYPE be the result of invoking Object.create with HTMLElement's interface prototype object as only argument".  But it doesn't say _which_ "HTMLElement's interface prototype object" should be used.

Then the spec says to run the "custom element constructor generation algorithm", but this algorithm assumes an ambient global, which the spec doesn't define.

In practice, the Chrome and Firefox implementations differ, as the attached testcase shows.  The output in Chrome:

  ctor instanceof iframe Function: false
  ctor instanceof parent Function: true
  proto comes from iframe: false
  proto comes from parent: true

The output in Firefox:

  ctor instanceof iframe Function: true
  ctor instanceof parent Function: false
  proto comes from iframe: true
  proto comes from parent: false

I believe the Firefox behavior is more correct here, by the way, since we're supposed to be using the registry of the iframe document, so should use its prototypes and constructors.

----

comment: 1
comment_url: https://www.w3.org/Bugs/Public/show_bug.cgi?id=27260#c1
*Boris Zbarsky* wrote on 2014-11-06 17:26:09 +0000.

Oh, and also, the "definition construction algorithm" is making assumptions about which global's prototypes or interfaces are supposed to be used.  This part is also not interoperable in Chrome and Firefox: Firefox seems to require that the passed-in proto come from the same global as the document involved, as you can see in the testcase.

---
Reply to this email directly or view it on GitHub:
https://github.com/w3c/webcomponents/issues/185

Received on Monday, 6 July 2015 07:39:27 UTC