OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <title>Custom element constructor sets value of IS attribute to custom element t
ype, 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 E
LEMENT's IS attribute to TYPE"> |
| 7 <link rel="help" href="http://www.w3.org/TR/custom-elements/#instantiating-custo
m-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"> |
| 12 </head> |
| 13 <body> |
| 14 <div id="log"></div> |
| 15 <script> |
| 16 test(function() { |
| 17 var doc = newHTMLDocument(); |
| 18 HTML5_ELEMENTS.forEach(function(tagName) { |
| 19 if (HTML5_DOCUMENT_ELEMENTS.indexOf(tagName) !== -1) { |
| 20 return; |
| 21 } |
| 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(); |
| 27 |
| 28 assert_equals(customElement.getAttribute('is'), name, |
| 29 'Value of the IS attribute should be set to type'); |
| 30 }); |
| 31 }, 'Test that the constructor of a type extension sets the IS attribute value to
the type'); |
| 32 |
| 33 |
| 34 test(function() { |
| 35 var doc = newHTMLDocument(); |
| 36 HTML5_ELEMENTS.forEach(function(tagName) { |
| 37 if (HTML5_DOCUMENT_ELEMENTS.indexOf(tagName) !== -1) { |
| 38 return; |
| 39 } |
| 40 var name = 'x-b-' + tagName; |
| 41 var GeneratedConstructor = doc.registerElement(name); |
| 42 var customElement = new GeneratedConstructor(); |
| 43 |
| 44 assert_false(customElement.hasAttribute('is'), |
| 45 'IS attribute should not present if local name is the same as type')
; |
| 46 }); |
| 47 }, 'Test that the constructor of a custom element does not set the IS attribute
if local name is the same as type'); |
| 48 </script> |
| 49 </body> |
| 50 </html> |
OLD | NEW |