4 <title>Custom element constructor sets value of IS attribute to custom element type, if it is not equal to name</title>
5 <meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
6 <meta name="assert" content="If TYPE is not the same as NAME, set the value of ELEMENT's IS attribute to TYPE">
7 <link rel="help" href="http://www.w3.org/TR/custom-elements/#instantiating-custom-elements">
8 <script src="../../../../resources/testharness.js"></script>
9 <script src="../../../../resources/testharnessreport.js"></script>
10 <script src="../testcommon.js"></script>
11 <link rel="stylesheet" href="../../../../resources/testharness.css">
17 var doc = newHTMLDocument();
18 HTML5_ELEMENTS.forEach(function(tagName) {
19 if (HTML5_DOCUMENT_ELEMENTS.indexOf(tagName) !== -1) {
22 var obj = doc.createElement(tagName);
23 var name = 'x-a-' + tagName;
24 var proto = Object.create(obj.constructor.prototype);
25 var GeneratedConstructor = doc.registerElement(name, {prototype: proto, extends: tagName});
26 var customElement = new GeneratedConstructor();
28 assert_equals(customElement.getAttribute('is'), name,
29 'Value of the IS attribute should be set to type');
31 }, 'Test that the constructor of a type extension sets the IS attribute value to the type');
35 var doc = newHTMLDocument();
36 HTML5_ELEMENTS.forEach(function(tagName) {
37 if (HTML5_DOCUMENT_ELEMENTS.indexOf(tagName) !== -1) {
40 var name = 'x-b-' + tagName;
41 var GeneratedConstructor = doc.registerElement(name);
42 var customElement = new GeneratedConstructor();
44 assert_false(customElement.hasAttribute('is'),
45 'IS attribute should not present if local name is the same as type');
47 }, 'Test that the constructor of a custom element does not set the IS attribute if local name is the same as type');