Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Custom]: Bogus createElement/createElementNS IDL. #10

Merged
merged 9 commits into from
May 8, 2014
25 changes: 18 additions & 7 deletions spec/custom/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -336,11 +336,11 @@ <h3 id="types-of-callbacks">Types of Callbacks</h3>
<dd>Unless specified otherwise, this callback <strong>must</strong> be <a href="#dfn-enqueue-lifecycle-callback">enqueued</a> whenever <a href="#dfn-custom-element">custom element</a>'s <a href="http://dom.spec.whatwg.org/#concept-attribute">attribute</a> is <a href="http://dom.spec.whatwg.org/#attribute-is-added">added</a>, <a href="http://dom.spec.whatwg.org/#attribute-is-changed">changed</a> or <a href="http://dom.spec.whatwg.org/#attribute-is-removed">removed</a>. Depending on the type of <a href="http://dom.spec.whatwg.org/#concept-attribute">attribute</a> modification, the following additional strings are added to the queue item:
<dl>
<dt><a href="http://dom.spec.whatwg.org/#attribute-is-added">attribute is set</a></dt>
<dd><a href="http://dom.spec.whatwg.org/#concept-attribute-name">attribute name</a>, <strong>null</strong> and new <a href="http://dom.spec.whatwg.org/#concept-attribute-value">attribute value</a></dd>
<dd><a href="http://dom.spec.whatwg.org/#concept-attribute-name">attribute name</a>, <strong>null</strong>, new <a href="http://dom.spec.whatwg.org/#concept-attribute-value">attribute value</a>, and the <a href="http://dom.spec.whatwg.org/#concept-attribute-namespace">attribute namespace</a>.</dd>
<dt><a href="http://dom.spec.whatwg.org/#attribute-is-changed">attribute is changed</a></dt>
<dd><a href="http://dom.spec.whatwg.org/#concept-attribute-name">attribute name</a>, old <a href="http://dom.spec.whatwg.org/#concept-attribute-value">attribute value</a> and new <a href="http://dom.spec.whatwg.org/#concept-attribute-value">attribute value</a></dd>
<dd><a href="http://dom.spec.whatwg.org/#concept-attribute-name">attribute name</a>, old <a href="http://dom.spec.whatwg.org/#concept-attribute-value">attribute value</a>, new <a href="http://dom.spec.whatwg.org/#concept-attribute-value">attribute value</a>, and the <a href="http://dom.spec.whatwg.org/#concept-attribute-namespace">attribute namespace</a>.</dd>
<dt><a href="http://dom.spec.whatwg.org/#attribute-is-removed">attribute is removed</a>
<dd><a href="http://dom.spec.whatwg.org/#concept-attribute-name">attribute name</a>, old <a href="http://dom.spec.whatwg.org/#concept-attribute-value">attribute value</a> and <strong>null</strong></dd>
<dd><a href="http://dom.spec.whatwg.org/#concept-attribute-name">attribute name</a>, old <a href="http://dom.spec.whatwg.org/#concept-attribute-value">attribute value</a>, <strong>null</strong>, and the <a href="http://dom.spec.whatwg.org/#concept-attribute-namespace">attribute namespace</a>.</dd>
</dl>
</dl>

Expand Down Expand Up @@ -372,6 +372,7 @@ <h2 id="creating-and-passing-registries">Creating and Passing Registries</h2>
<ul>
<li>When <a href="http://dom.spec.whatwg.org/#interface-domimplementation"><code>DOMImplementation</code></a>'s <a href="http://dom.spec.whatwg.org/#dom-domimplementation-createdocument"><code>createDocument</code></a> method is invoked with <em>namespace</em> set to <a href="http://www.w3.org/1999/xhtml/">HTML Namespace</a> or when the <a href="http://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument"><code>createHTMLDocument</code></a> method is invoked, use the <a href="#dfn-registry">registry</a> of the associated <a href="http://dom.spec.whatwg.org/#concept-document">document</a> to the new instance.</li>
<li>When creating an <a href="https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/imports/index.html#dfn-import">import</a>, use the <a href="#dfn-registry">registry</a> of the <a href="https://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/imports/index.html#dfn-master-document">master document</a>.</li>
<li>When creating a <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/scripting-1.html#appropriate-template-contents-owner-document">template contents owner document</a>, use a new empty <a href="#dfn-registry">registry</a>.</li>
</ul>

<p>In all other cases, new <a href="http://dom.spec.whatwg.org/#concept-document">documents</a> <strong>must not</strong> have a <a href="#dfn-registry">registry</a>.</p>
Expand Down Expand Up @@ -531,11 +532,21 @@ <h3 id="extensions-to-document-interface-to-register">Extensions to <a href="htt
},
// specify more members for your prototype.
// ...
})
}),
extends: 'p'
});

</code></pre>
<p>Note the use of <code>extends</code> option to specify that the element is being registered as a <a href="#dfn-type-extension">type extension</a> -- that is, this element does not introduce a new tag (like the <a href="#dfn-custom-tag">custom tag</a> elements do), but rather extends an existing element of type <strong>HTMLParagraphElement</strong>. Here's how one could instantiate this element:</p>
<pre><code class="prettyprint">
&lt;p is="x-foo"&gt;Paragraph of amazement&lt;/p&gt;
</code></pre>
Or imperatively, in JavaScript:
<pre><code class="prettyprint">
var foo = document.createElement('p', 'x-foo');
</code></pre>
</div>
<p>Elements with <code>SVGElement</code> prototype deserve a special mention: using <a href="#dfn-custom-tag">custom tag</a> approach results in <a href="http://www.w3.org/TR/SVG11/extend.html#ForeignNamespaces">ignored elements</a> in SVG. Thus, your SVG-based custom elements would almost always be <a href="#dfn-type-extension">type extensions</a>.</p>

<h3 id="unresolved-element-pseudoclass">Unresolved Element Pseudoclass</h3>

Expand Down Expand Up @@ -586,12 +597,12 @@ <h2 id="instantiating-custom-elements">Instantiating Custom Elements</h2>

<h3 id="extensions-to-document-interface-to-instantiate">Extensions to <a href="http://dom.spec.whatwg.org/#document"><code>Document</code></a> Interface</h3>

<p>To allow creating both <a href="#dfn-custom-tag">custom tag</a> and <a href="#dfn-type-extension">type extension</a>-style <a href="#dfn-custom-element">custom elements</a>, the <a href="http://dom.spec.whatwg.org/#dom-document-createelement"><code>createElement</code></a> or <a href="http://dom.spec.whatwg.org/#dom-document-createelementns"><codE>createElementNS</code></a> methods have an optional <code>typeExtension</code> argument:</p>
<p>To allow creating both <a href="#dfn-custom-tag">custom tag</a> and <a href="#dfn-type-extension">type extension</a>-style <a href="#dfn-custom-element">custom elements</a>, the <a href="http://dom.spec.whatwg.org/#dom-document-createelement"><code>createElement</code></a> or <a href="http://dom.spec.whatwg.org/#dom-document-createelementns"><codE>createElementNS</code></a> methods have <a href="http://heycam.github.io/webidl/#idl-overloading">overloads</a> with a <code>typeExtension</code> argument:</p>

<pre><code>
partial interface <a href="http://dom.spec.whatwg.org/#document">Document</a> {
<a href="http://dom.spec.whatwg.org/#element">Element</a> createElement(DOMString localName, optional DOMString typeExtension);
<a href="http://dom.spec.whatwg.org/#element">Element</a> createElementNS(DOMString? namespace, DOMString qualifiedName, optional DOMString typeExtension);
<a href="http://dom.spec.whatwg.org/#element">Element</a> createElement(DOMString localName, DOMString typeExtension);
<a href="http://dom.spec.whatwg.org/#element">Element</a> createElementNS(DOMString? namespace, DOMString qualifiedName, DOMString typeExtension);
};
</code></pre>
<p></p>
Expand Down