<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>22827</bug_id>
          
          <creation_ts>2013-07-29 04:58:22 +0000</creation_ts>
          <short_desc>[Custom]: Confusing condition on documents and registration contexts in constructor invocation</short_desc>
          <delta_ts>2013-08-08 16:27:30 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>HISTORICAL - Component Model</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          <blocked>14968</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Dominic Cooney">dominicc</reporter>
          <assigned_to name="Dimitri Glazkov">dglazkov</assigned_to>
          
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>91369</commentid>
    <comment_count>0</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2013-07-29 04:58:22 +0000</bug_when>
    <thetext>The constructor generation algorithm says

&quot;DOCUMENT [is] the owner document for new custom element&quot;

Then

&quot;Let CONTEXT be the registration context of DOCUMENT&quot;

and later

&quot;If the registration context of ELEMENT&apos;s document is different from CONTEXT, throw an InvalidStateError and stop.&quot;

It is not clear to me how this error could arise, since the owner document for the new custom element&apos;s registration context is by definition the registration context of element&apos;s document.

I think it would be simpler if generated constructors worked like the image constructor does, which is:

&quot;The element&apos;s document must be the active document of the browsing context of the Window object on which the interface object of the invoked constructor is found.&quot;

This won&apos;t exactly work, because the generated constructor is not defined on a Window object per se. But something like this would make the implementation better--as it is, we have to keep the document the definition was registered against alive just to own elements until they can be adopted into their ultimate destination.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91743</commentid>
    <comment_count>1</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-08-07 20:44:11 +0000</bug_when>
    <thetext>(In reply to comment #0)
&gt; The constructor generation algorithm says
&gt; 
&gt; &quot;DOCUMENT [is] the owner document for new custom element&quot;
&gt; 
&gt; Then
&gt; 
&gt; &quot;Let CONTEXT be the registration context of DOCUMENT&quot;
&gt; 
&gt; and later
&gt; 
&gt; &quot;If the registration context of ELEMENT&apos;s document is different from
&gt; CONTEXT, throw an InvalidStateError and stop.&quot;
&gt; 
&gt; It is not clear to me how this error could arise, since the owner document
&gt; for the new custom element&apos;s registration context is by definition the
&gt; registration context of element&apos;s document.

This is meant to describe the situation when a constructor from frame A is called in frame B. But at the time when constructor runs, element&apos;s document is unknown, so I messed up.

&gt; I think it would be simpler if generated constructors worked like the image
&gt; constructor does, which is:
&gt; 
&gt; &quot;The element&apos;s document must be the active document of the browsing context
&gt; of the Window object on which the interface object of the invoked
&gt; constructor is found.&quot;
&gt; 
&gt; This won&apos;t exactly work, because the generated constructor is not defined on
&gt; a Window object per se. But something like this would make the
&gt; implementation better--as it is, we have to keep the document the definition
&gt; was registered against alive just to own elements until they can be adopted
&gt; into their ultimate destination.

I can work with this.

https://dvcs.w3.org/hg/webcomponents/rev/9ebeedebe488

WDYT?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91778</commentid>
    <comment_count>2</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2013-08-08 08:04:01 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; https://dvcs.w3.org/hg/webcomponents/rev/9ebeedebe488
&gt; 
&gt; WDYT?

I think it is implementable. It seems draconian--why not just let the constructor run, but create an element in the browsing context&apos;s document?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91796</commentid>
    <comment_count>3</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-08-08 16:20:03 +0000</bug_when>
    <thetext>(In reply to comment #2)
&gt; (In reply to comment #1)
&gt; &gt; https://dvcs.w3.org/hg/webcomponents/rev/9ebeedebe488
&gt; &gt; 
&gt; &gt; WDYT?
&gt; 
&gt; I think it is implementable. It seems draconian--why not just let the
&gt; constructor run, but create an element in the browsing context&apos;s document?

That&apos;s a good question. I guess the original intent was to protect the user from creating scripting context entanglements, but I think you&apos;re asking if this is too nanny-state of us.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91799</commentid>
    <comment_count>4</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-08-08 16:27:30 +0000</bug_when>
    <thetext>(In reply to comment #3)
&gt; (In reply to comment #2)
&gt; &gt; (In reply to comment #1)
&gt; &gt; &gt; https://dvcs.w3.org/hg/webcomponents/rev/9ebeedebe488
&gt; &gt; &gt; 
&gt; &gt; &gt; WDYT?
&gt; &gt; 
&gt; &gt; I think it is implementable. It seems draconian--why not just let the
&gt; &gt; constructor run, but create an element in the browsing context&apos;s document?

Poured this comment into bug 20488.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>