This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 27260 - [Custom]: Need to define global/Realm handling for registerElement
Summary: [Custom]: Need to define global/Realm handling for registerElement
Status: RESOLVED MOVED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: HISTORICAL - Component Model (show other bugs)
Version: unspecified
Hardware: PC All
: P2 normal
Target Milestone: ---
Assignee: Dimitri Glazkov
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 14968
  Show dependency treegraph
 
Reported: 2014-11-06 17:18 UTC by Boris Zbarsky
Modified: 2015-07-06 08:13 UTC (History)
2 users (show)

See Also:


Attachments
Testcase (1.14 KB, text/html)
2014-11-06 17:18 UTC, Boris Zbarsky
Details

Description Boris Zbarsky 2014-11-06 17:18:44 UTC
Created attachment 1535 [details]
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 Boris Zbarsky 2014-11-06 17:26:09 UTC
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.
Comment 2 Hayato Ito 2015-07-06 08:13:35 UTC
Moved to https://github.com/w3c/webcomponents/issues/185