<?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>20299</bug_id>
          
          <creation_ts>2012-12-08 02:01:52 +0000</creation_ts>
          <short_desc>[Custom]: Extensions to the document interface are not valid WebIDL</short_desc>
          <delta_ts>2012-12-11 19:31:37 +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>All</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>17103</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Boris Zbarsky">bzbarsky</reporter>
          <assigned_to name="Dimitri Glazkov">dglazkov</assigned_to>
          <cc>bugs</cc>
    
    <cc>bzbarsky</cc>
    
    <cc>cam</cc>
    
    <cc>wchen</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>79737</commentid>
    <comment_count>0</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2012-12-08 02:01:52 +0000</bug_when>
    <thetext>The spec draft says:

  partial interface Document { 
    Function register(DOMString name, optional Options options);
  } 
  dictionary Options { 
    object? prototype; 
    DocumentFragment? template; 
    LifecycleCallbacks? lifecycle; 
  }
  dictionary LifecycleCallbacks {
     void created(); 
  }

There are a bunch of issues here:

1) There need to be semicolons between the toplevel things.
2) Putting a generic name like &quot;Options&quot; in a flat namespace is a bit weird.  It
   needs a name that&apos;s less likely to be confusing to people and less likely to
   cause collisions.
3) &quot;optional&quot; is not valid on dictionary arguments.  They&apos;re always optional, so
   adding it gives you a parse error.
4) LifecycleCallbacks is presumably meant to be a callback interface, not a
   dictionary right?  But did you really want to use a callback interface here,
   not a callback function?
5) There seems to be some confusion in the prose that follows because it only
   talks about what to do if &quot;prototype&quot; is missing, say, not what to do if
   it&apos;s null.  Strictly speaking, the current spec says to throw if it&apos;s null,
   but then it makes no sense to declare it nullable in the dictionary.
6) Nothing says what should happen if &quot;template&quot; is missing.
7) Nothing says what should happen if &quot;callbacks&quot; are missing.

In any case, something like this might be more what you meant:

  callback ElementConstructor = Element();
  partial interface Document { 
    ElementConstructor register(DOMString name,
                                ElementRegistrationOptions options);
  };
  dictionary ElementRegistrationOptions { 
    object? prototype = null; 
    DocumentFragment? template = null; 
    LifecycleCallbacks? lifecycle = null; 
  };
  callback interface LifecycleCallbacks {
     void created(); 
  };

and then you don&apos;t have to worry about missing optional things, only null ones.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79788</commentid>
    <comment_count>1</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2012-12-10 04:16:33 +0000</bug_when>
    <thetext>&gt; 3) &quot;optional&quot; is not valid on dictionary arguments.  They&apos;re always optional,
&gt;     so adding it gives you a parse error.

Sorry, that part is a lie.  It&apos;s omitting the &quot;optional&quot; that&apos;s not OK.

The rest is still true, I believe.  ;)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79863</commentid>
    <comment_count>2</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2012-12-10 21:42:27 +0000</bug_when>
    <thetext>(In reply to comment #0)

Thank you for looking this over!

&gt; The spec draft says:
&gt; 
&gt;   partial interface Document { 
&gt;     Function register(DOMString name, optional Options options);
&gt;   } 
&gt;   dictionary Options { 
&gt;     object? prototype; 
&gt;     DocumentFragment? template; 
&gt;     LifecycleCallbacks? lifecycle; 
&gt;   }
&gt;   dictionary LifecycleCallbacks {
&gt;      void created(); 
&gt;   }
&gt; 
&gt; There are a bunch of issues here:
&gt; 
&gt; 1) There need to be semicolons between the toplevel things.

http://dvcs.w3.org/hg/webcomponents/rev/7a51557797a9

&gt; 2) Putting a generic name like &quot;Options&quot; in a flat namespace is a bit weird.
&gt; It
&gt;    needs a name that&apos;s less likely to be confusing to people and less likely
&gt; to
&gt;    cause collisions.

http://dvcs.w3.org/hg/webcomponents/rev/80d7af3a9111

&gt; 3) &quot;optional&quot; is not valid on dictionary arguments.  They&apos;re always
&gt; optional, so
&gt;    adding it gives you a parse error.

Good thing I saw your next comment :P

&gt; 4) LifecycleCallbacks is presumably meant to be a callback interface, not a
&gt;    dictionary right?  But did you really want to use a callback interface
&gt; here,
&gt;    not a callback function?

Oh yes! Callback interface is a better fit.

http://dvcs.w3.org/hg/webcomponents/rev/cb0d68b7de41

As for being the function -- there will be more callbacks in this dictionary:

https://www.w3.org/Bugs/Public/show_bug.cgi?id=18748
http://www.w3.org/TR/components-intro/#appendix-a-interfaces
(Note, this document is out of date, I haven&apos;t gotten to catching it up with the rest of the specifications yet).

&gt; 5) There seems to be some confusion in the prose that follows because it only
&gt;    talks about what to do if &quot;prototype&quot; is missing, say, not what to do if
&gt;    it&apos;s null.  Strictly speaking, the current spec says to throw if it&apos;s
&gt; null,
&gt;    but then it makes no sense to declare it nullable in the dictionary.

http://dvcs.w3.org/hg/webcomponents/rev/3fa09764a196

&gt; 6) Nothing says what should happen if &quot;template&quot; is missing.

http://dvcs.w3.org/hg/webcomponents/rev/6a0c8a13f13d

&gt; 7) Nothing says what should happen if &quot;callbacks&quot; are missing.

With the null/missing treatment unified, the steps now make sense.
 
&gt; In any case, something like this might be more what you meant:
&gt; 
&gt;   callback ElementConstructor = Element();
&gt;   partial interface Document { 
&gt;     ElementConstructor register(DOMString name,
&gt;                                 ElementRegistrationOptions options);
&gt;   };
&gt;   dictionary ElementRegistrationOptions { 
&gt;     object? prototype = null; 
&gt;     DocumentFragment? template = null; 
&gt;     LifecycleCallbacks? lifecycle = null; 
&gt;   };
&gt;   callback interface LifecycleCallbacks {
&gt;      void created(); 
&gt;   };
&gt; 
&gt; and then you don&apos;t have to worry about missing optional things, only null
&gt; ones.

Did I get them all? :)

Not sure whether I should just use function ElementConstructor syntax yet. Sent mail to the list.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79865</commentid>
    <comment_count>3</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2012-12-10 21:44:51 +0000</bug_when>
    <thetext>*** Bug 20242 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79867</commentid>
    <comment_count>4</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2012-12-10 22:04:37 +0000</bug_when>
    <thetext>&gt; Did I get them all? :)

Looks like it, yes.  I wouldn&apos;t worry too much about the exact type of ElementConstructor for the moment, while WebIDL gets sorted out around there.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79869</commentid>
    <comment_count>5</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2012-12-10 22:17:26 +0000</bug_when>
    <thetext>(In reply to comment #4)
&gt; &gt; Did I get them all? :)
&gt; 
&gt; Looks like it, yes.  I wouldn&apos;t worry too much about the exact type of
&gt; ElementConstructor for the moment, while WebIDL gets sorted out around there.

Cool! Filed bug 20329 so I don&apos;t forget.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79947</commentid>
    <comment_count>6</comment_count>
    <who name="William Chen">wchen</who>
    <bug_when>2012-12-11 19:09:01 +0000</bug_when>
    <thetext>The use of &quot;prototype&quot; as an identifier in the ElementRegistrationOptions dictionary is also invalid because it&apos;s a reserved identifier.

http://www.w3.org/TR/WebIDL/#idl-names</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79948</commentid>
    <comment_count>7</comment_count>
    <who name="Boris Zbarsky">bzbarsky</who>
    <bug_when>2012-12-11 19:14:04 +0000</bug_when>
    <thetext>That seems like a WebIDL bug to me, at first glance...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79950</commentid>
    <comment_count>8</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2012-12-11 19:31:37 +0000</bug_when>
    <thetext>(In reply to comment #6)
&gt; The use of &quot;prototype&quot; as an identifier in the ElementRegistrationOptions
&gt; dictionary is also invalid because it&apos;s a reserved identifier.
&gt; 
&gt; http://www.w3.org/TR/WebIDL/#idl-names

Filed bug 20346 to track this.

First reaction same as Boris&apos; --&gt; unless the object is a Function, seems like .prototype should be allowed.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>