<?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>18596</bug_id>
          
          <creation_ts>2012-08-16 16:37:32 +0000</creation_ts>
          <short_desc>[Custom]: Use a &quot;has a&quot; relationship instead of &quot;is a&quot; for custom types</short_desc>
          <delta_ts>2013-05-29 19:21:18 +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>Windows NT</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</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>18511</blocked>
          <everconfirmed>1</everconfirmed>
          <reporter name="Tony Ross [MSFT]">tross</reporter>
          <assigned_to name="Dimitri Glazkov">dglazkov</assigned_to>
          <cc>dominicc</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>72295</commentid>
    <comment_count>0</comment_count>
    <who name="Tony Ross [MSFT]">tross</who>
    <bug_when>2012-08-16 16:37:32 +0000</bug_when>
    <thetext>Perhaps this has been discussed before, but I think we could simplify custom elements significantly by creating a &apos;custom&apos; property (or some similar name) on HTMLElement. This property would hold the instance of the created custom element type (and return null until the custom type was bound).

E.g. instead of:

    elm.myCustomMethod()

You get:

    elm.custom.myCustomMethod()

This has a number of effects:

1. The concept of &quot;upgrading&quot; an element to a custom element no longer requires mutating the DOM tree or the prototype chain. 

2. Makes it obvious whether or not a custom type has been bound (just check if elm.custom is truthy).

3. Eliminates the risk of custom APIs masking future, standardized DOM APIs.

4. Clearly indicates to the consumer of a component which APIs are custom vs. native.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>72327</commentid>
    <comment_count>1</comment_count>
    <who name="Dominic Cooney">dominicc</who>
    <bug_when>2012-08-17 02:24:52 +0000</bug_when>
    <thetext>(In reply to comment #0)
&gt; … This property would hold the instance of the created custom
&gt; element type (and return null until the custom type was bound).
&gt; 
&gt; E.g. instead of:
&gt; 
&gt;     elm.myCustomMethod()
&gt; 
&gt; You get:
&gt; 
&gt;     elm.custom.myCustomMethod()

The proposal has benefits. But it has these downsides.

The consumer must dereference custom.

The consumer must recall, is the property they want on the DOM object? Or the custom object?

The consumer must expect disappointment with this:

var goodies = elm.custom;
… enjoy goodies …
document.body.appendChild(goodies);

One logical element has been split in half.

This has downsides for the component author too.

What does &apos;this&apos; refer to? Neither is the whole. So the component author must dereference. And recall, is the property they want on the custom object? Or the DOM object?

There is no place to override behavior. You’re writing a timezone picker. The semantic element is &lt;select&gt;. Do you put a selectedIndex property on every instance? A prototype would have helped.

&gt; This has a number of effects:
&gt; 
&gt; 1. The concept of &quot;upgrading&quot; an element to a custom element no longer requires
&gt; mutating the DOM tree or the prototype chain. 

Mutating the DOM tree makes me squeamish too. But it is the best choice.

Mutating the prototype chain isn’t countenanced by either proposal.

&gt; 2. Makes it obvious whether or not a custom type has been bound (just check if
&gt; elm.custom is truthy).

True.

What about

elm instanceof TimeZonePicker

which makes it obvious whether elm has been bound, and to what.

&gt; 3. Eliminates the risk of custom APIs masking future, standardized DOM APIs.

DOM already carries this risk. Did it materialize? Was it serious?

&gt; 4. Clearly indicates to the consumer of a component which APIs are custom vs.
&gt; native.

It is a specious distinction. Native APIs can be replaced.

The consumer values expediency.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>88390</commentid>
    <comment_count>2</comment_count>
    <who name="Dimitri Glazkov">dglazkov</who>
    <bug_when>2013-05-29 19:21:18 +0000</bug_when>
    <thetext>We took the approach that closely matches how any DOM element (custom or not) is created.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>