Changeset 197602 in webkit
- Timestamp:
- Mar 4, 2016 5:23:42 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 18 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r197594 r197602 1 2016-03-04 Ryosuke Niwa <rniwa@webkit.org> 2 3 Update defineCustomElement according to the spec rewrite 4 https://bugs.webkit.org/show_bug.cgi?id=155010 5 <rdar://problem/24970878> 6 7 Reviewed by Chris Dumez. 8 9 Update the tests for the rename and semantics change of defineCustomElement and HTMLElement constructor. 10 11 * fast/custom-elements/Document-createElement.html: 12 * fast/custom-elements/Document-defineCustomElement-expected.txt: Removed. 13 * fast/custom-elements/Document-defineCustomElement.html: Removed. 14 * fast/custom-elements/Document-defineElement-expected.txt: Renamed from LayoutTests/fast/custom-elements/Document-defineCustomElement-expected.txt. 15 * fast/custom-elements/Document-defineElement.html: Renamed from LayoutTests/fast/custom-elements/Document-defineCustomElement.html. 16 Also added a test case for defining multiple custom elements with a single class, which must throw. 17 * fast/custom-elements/HTMLElement-constructor-expected.txt: 18 * fast/custom-elements/HTMLElement-constructor.html: 19 Removed test cases for the tag name in the first argument as well as ones that associate a single class with multiple tag names. 20 * fast/custom-elements/parser/parser-constructs-custom-element-in-document-write.html: 21 * fast/custom-elements/parser/parser-constructs-custom-element-synchronously.html: 22 * fast/custom-elements/parser/parser-constructs-custom-elements.html: 23 * fast/custom-elements/parser/parser-fallsback-to-unknown-element.html: 24 * fast/custom-elements/parser/parser-sets-attributes-and-children.html: 25 * fast/custom-elements/parser/parser-uses-constructed-element.html: 26 * fast/custom-elements/parser/parser-uses-registry-of-owner-document.html: 27 1 28 2016-03-04 Simon Fraser <simon.fraser@apple.com> 2 29 -
trunk/LayoutTests/fast/custom-elements/Document-createElement.html
r195538 r197602 19 19 assert_false(document.createElement('my-custom-element') instanceof MyCustomElement); 20 20 21 document.define CustomElement('my-custom-element', MyCustomElement);21 document.defineElement('my-custom-element', MyCustomElement); 22 22 var instance = document.createElement('my-custom-element'); 23 23 assert_true(instance instanceof MyCustomElement); … … 34 34 } 35 35 }; 36 document.define CustomElement('object-custom-element', ObjectCustomElement);36 document.defineElement('object-custom-element', ObjectCustomElement); 37 37 38 38 var instance = new ObjectCustomElement; … … 50 50 } 51 51 }; 52 document.define CustomElement('text-custom-element', TextCustomElement);52 document.defineElement('text-custom-element', TextCustomElement); 53 53 assert_true(new TextCustomElement instanceof Text); 54 54 assert_equals(document.createElement('object-custom-element'), null); … … 65 65 } 66 66 }; 67 document.define CustomElement('div-custom-element', DivCustomElement);67 document.defineElement('div-custom-element', DivCustomElement); 68 68 assert_true(new DivCustomElement instanceof HTMLDivElement); 69 69 … … 83 83 } 84 84 }; 85 document.define CustomElement('throw-custom-element', ThrowCustomElement);85 document.defineElement('throw-custom-element', ThrowCustomElement); 86 86 87 87 assert_throws(null, function () { new ThrowCustomElement; }); -
trunk/LayoutTests/fast/custom-elements/Document-defineElement-expected.txt
r197596 r197602 1 1 2 PASS Check the existence of defineCustomElement on Document interface 3 PASS document.defineCustomElement should throw with an invalid name 4 PASS document.defineCustomElement should throw with a duplicate name 5 PASS document.defineCustomElement must throw a NotSupportedError when the context object is an associated inert template document 6 PASS document.defineCustomElement must throw a NotSupportedError when the context object is created by DOMImplementation.createHTMLDocument 7 PASS document.defineCustomElement must throw a NotSupportedError when the context object is created by DOMImplementation.createDocument 8 PASS document.defineCustomElement should throw when the element interface is not a constructor 9 PASS document.defineCustomElement should define an instantiatable custom element 2 PASS Check the existence of defineElement on Document interface 3 PASS document.defineElement should throw with an invalid name 4 PASS document.defineElement should throw when there is already a custom element of the same name 5 PASS document.defineElement should throw when there is already a custom element with the same class 6 PASS document.defineElement must throw a NotSupportedError when the context object is an associated inert template document 7 PASS document.defineElement must throw a NotSupportedError when the context object is created by DOMImplementation.createHTMLDocument 8 PASS document.defineElement must throw a NotSupportedError when the context object is created by DOMImplementation.createDocument 9 PASS document.defineElement should throw when the element interface is not a constructor 10 PASS document.defineElement should define an instantiatable custom element 10 11 -
trunk/LayoutTests/fast/custom-elements/Document-defineElement.html
r197596 r197602 4 4 <title>Custom Elements: Extensions to Document interface</title> 5 5 <meta name="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org"> 6 <meta name="assert" content="document.define CustomElement should define a custom element">6 <meta name="assert" content="document.defineElement should define a custom element"> 7 7 <script src="../../resources/testharness.js"></script> 8 8 <script src="../../resources/testharnessreport.js"></script> … … 14 14 15 15 test(function () { 16 assert_true('define CustomElement' in Document.prototype, '"defineCustomElement" exists on Document.prototype');17 assert_true('define CustomElement' in document, '"defineCustomElement" exists on document');18 }, 'Check the existence of define CustomElement on Document interface');16 assert_true('defineElement' in Document.prototype, '"defineElement" exists on Document.prototype'); 17 assert_true('defineElement' in document, '"defineElement" exists on document'); 18 }, 'Check the existence of defineElement on Document interface'); 19 19 20 20 test(function () { 21 21 class MyCustomElement extends HTMLElement {}; 22 22 23 assert_throws({'name': 'SyntaxError'}, function () { document.define CustomElement(null, MyCustomElement); },24 'document.define CustomElement must throw a SyntaxError if the tag name is null');25 assert_throws({'name': 'SyntaxError'}, function () { document.define CustomElement('', MyCustomElement); },26 'document.define CustomElement must throw a SyntaxError if the tag name is empty');27 assert_throws({'name': 'SyntaxError'}, function () { document.define CustomElement('abc', MyCustomElement); },28 'document.define CustomElement must throw a SyntaxError if the tag name does not contain "-"');29 assert_throws({'name': 'SyntaxError'}, function () { document.define CustomElement('a-Bc', MyCustomElement); },30 'document.define CustomElement must throw a SyntaxError if the tag name contains an upper case letter');23 assert_throws({'name': 'SyntaxError'}, function () { document.defineElement(null, MyCustomElement); }, 24 'document.defineElement must throw a SyntaxError if the tag name is null'); 25 assert_throws({'name': 'SyntaxError'}, function () { document.defineElement('', MyCustomElement); }, 26 'document.defineElement must throw a SyntaxError if the tag name is empty'); 27 assert_throws({'name': 'SyntaxError'}, function () { document.defineElement('abc', MyCustomElement); }, 28 'document.defineElement must throw a SyntaxError if the tag name does not contain "-"'); 29 assert_throws({'name': 'SyntaxError'}, function () { document.defineElement('a-Bc', MyCustomElement); }, 30 'document.defineElement must throw a SyntaxError if the tag name contains an upper case letter'); 31 31 32 32 var builtinTagNames = [ … … 42 42 43 43 for (var tagName of builtinTagNames) { 44 assert_throws({'name': 'SyntaxError'}, function () { document.define CustomElement(tagName, MyCustomElement); },45 'document.define CustomElement must throw a SyntaxError if the tag name is "' + tagName + '"');44 assert_throws({'name': 'SyntaxError'}, function () { document.defineElement(tagName, MyCustomElement); }, 45 'document.defineElement must throw a SyntaxError if the tag name is "' + tagName + '"'); 46 46 } 47 47 48 }, 'document.define CustomElement should throw with an invalid name');48 }, 'document.defineElement should throw with an invalid name'); 49 49 50 50 test(function () { … … 52 52 class OtherCustomElement extends HTMLElement {}; 53 53 54 document.define CustomElement('some-custom-element', SomeCustomElement);55 assert_throws({'name': 'NotSupportedError'}, function () { document.define CustomElement('some-custom-element', OtherCustomElement); },56 'document.define CustomElement must throw a NotSupportedError if the specified tag name is already used');54 document.defineElement('some-custom-element', SomeCustomElement); 55 assert_throws({'name': 'NotSupportedError'}, function () { document.defineElement('some-custom-element', OtherCustomElement); }, 56 'document.defineElement must throw a NotSupportedError if the specified tag name is already used'); 57 57 58 }, 'document.defineCustomElement should throw with a duplicate name'); 58 }, 'document.defineElement should throw when there is already a custom element of the same name'); 59 60 test(function () { 61 class AnotherCustomElement extends HTMLElement {}; 62 63 document.defineElement('another-custom-element', AnotherCustomElement); 64 assert_throws({'name': 'NotSupportedError'}, function () { document.defineElement('some-other-element', AnotherCustomElement); }, 65 'document.defineElement must throw a NotSupportedError if the specified class already defines an element'); 66 67 }, 'document.defineElement should throw when there is already a custom element with the same class'); 59 68 60 69 test(function () { … … 63 72 var templateContentOwnerDocument = document.createElement('template').content.ownerDocument; 64 73 assert_throws({'name': 'NotSupportedError'}, function () { 65 templateContentOwnerDocument.define CustomElement('some-custom-element', SomeCustomElement);74 templateContentOwnerDocument.defineElement('some-custom-element', SomeCustomElement); 66 75 }); 67 76 68 }, 'document.define CustomElement must throw a NotSupportedError when the context object is an associated inert template document');77 }, 'document.defineElement must throw a NotSupportedError when the context object is an associated inert template document'); 69 78 70 79 test(function () { … … 73 82 var windowlessDocument = document.implementation.createHTMLDocument(); 74 83 assert_throws({'name': 'NotSupportedError'}, function () { 75 windowlessDocument.define CustomElement('some-custom-element', SomeCustomElement);84 windowlessDocument.defineElement('some-custom-element', SomeCustomElement); 76 85 }); 77 86 78 }, 'document.define CustomElement must throw a NotSupportedError when the context object is created by DOMImplementation.createHTMLDocument');87 }, 'document.defineElement must throw a NotSupportedError when the context object is created by DOMImplementation.createHTMLDocument'); 79 88 80 89 test(function () { … … 83 92 var windowlessDocument = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', null) 84 93 assert_throws({'name': 'NotSupportedError'}, function () { 85 windowlessDocument.define CustomElement('some-custom-element', SomeCustomElement);94 windowlessDocument.defineElement('some-custom-element', SomeCustomElement); 86 95 }); 87 96 88 }, 'document.define CustomElement must throw a NotSupportedError when the context object is created by DOMImplementation.createDocument');97 }, 'document.defineElement must throw a NotSupportedError when the context object is created by DOMImplementation.createDocument'); 89 98 90 99 test(function () { 91 assert_throws({'name': 'TypeError'}, function () { document.define CustomElement('invalid-element', 1); },92 'document.define CustomElement must throw a TypeError when the element interface is a number');93 assert_throws({'name': 'TypeError'}, function () { document.define CustomElement('invalid-element', '123'); },94 'document.define CustomElement must throw a TypeError when the element interface is a string');95 assert_throws({'name': 'TypeError'}, function () { document.define CustomElement('invalid-element', {}); },96 'document.define CustomElement must throw a TypeError when the element interface is an object');97 assert_throws({'name': 'TypeError'}, function () { document.define CustomElement('invalid-element', []); },98 'document.define CustomElement must throw a TypeError when the element interface is an array');99 }, 'document.define CustomElement should throw when the element interface is not a constructor');100 assert_throws({'name': 'TypeError'}, function () { document.defineElement('invalid-element', 1); }, 101 'document.defineElement must throw a TypeError when the element interface is a number'); 102 assert_throws({'name': 'TypeError'}, function () { document.defineElement('invalid-element', '123'); }, 103 'document.defineElement must throw a TypeError when the element interface is a string'); 104 assert_throws({'name': 'TypeError'}, function () { document.defineElement('invalid-element', {}); }, 105 'document.defineElement must throw a TypeError when the element interface is an object'); 106 assert_throws({'name': 'TypeError'}, function () { document.defineElement('invalid-element', []); }, 107 'document.defineElement must throw a TypeError when the element interface is an array'); 108 }, 'document.defineElement should throw when the element interface is not a constructor'); 100 109 101 110 test(function () { 102 111 class MyCustomElement extends HTMLElement {}; 103 document.define CustomElement('my-custom-element', MyCustomElement);112 document.defineElement('my-custom-element', MyCustomElement); 104 113 105 114 var instance = new MyCustomElement; … … 116 125 'A custom element HTML must use HTML namespace'); 117 126 118 }, 'document.define CustomElement should define an instantiatable custom element');127 }, 'document.defineElement should define an instantiatable custom element'); 119 128 120 129 </script> -
trunk/LayoutTests/fast/custom-elements/HTMLElement-constructor-expected.txt
r195087 r197602 3 3 PASS HTMLElement constructor must throw TypeError when custom element is not well defined 4 4 PASS HTMLElement constructor must infer the tag name from the element interface 5 PASS HTMLElement constructor must allow associating an element interface with multiple tag names6 5 PASS HTMLElement constructor must allow subclassing a custom element 7 6 PASS HTMLElement constructor must allow subclassing an user-defined subclass of HTMLElement -
trunk/LayoutTests/fast/custom-elements/HTMLElement-constructor.html
r195087 r197602 15 15 test(function () { 16 16 class SomeDefinedElement extends HTMLElement {}; 17 document.define CustomElement('defined-element', SomeDefinedElement);17 document.defineElement('defined-element', SomeDefinedElement); 18 18 assert_throws({'name': 'TypeError'}, function () { new HTMLElement('defined-element'); }); 19 19 }, 'HTMLElement constructor must throw a TypeError when there is no derived class'); … … 22 22 class SomeCustomElement extends HTMLElement {}; 23 23 assert_throws({'name': 'TypeError'}, function () { new SomeCustomElement; }, 24 'Instantiating a custom element without calling defineCustomElement must throw TypeError'); 25 26 class AnotherCustomElement extends HTMLElement { 27 constructor() { super('some-element'); } 28 }; 29 document.defineCustomElement('another-element', AnotherCustomElement); 30 assert_throws({'name': 'TypeError'}, function () { new AnotherCustomElement; }, 31 'Calling HTMLElement constructor with a mismatching tag name throw TypeError'); 32 33 class YetAnotherCustomElement extends HTMLElement { 34 constructor() { super(1); } 35 }; 36 document.defineCustomElement('yet-another-element', YetAnotherCustomElement); 37 assert_throws({'name': 'TypeError'}, function () { new YetAnotherCustomElement; }, 38 'Calling HTMLElement constructor with a bad tag name throw TypeError'); 39 24 'Instantiating a custom element without calling defineElement must throw TypeError'); 40 25 }, 'HTMLElement constructor must throw TypeError when custom element is not well defined'); 41 26 42 27 test(function () { 43 28 class CustomElementWithInferredTagName extends HTMLElement {}; 44 document.define CustomElement('inferred-name', CustomElementWithInferredTagName);29 document.defineElement('inferred-name', CustomElementWithInferredTagName); 45 30 46 31 var instance = new CustomElementWithInferredTagName; … … 60 45 61 46 test(function () { 62 class ElementWithMultipleTagNames extends HTMLElement { };63 document.defineCustomElement('custom-element-1', ElementWithMultipleTagNames);64 document.defineCustomElement('custom-element-2', ElementWithMultipleTagNames);65 66 var instance1 = new ElementWithMultipleTagNames('custom-element-1');67 assert_true(instance1 instanceof ElementWithMultipleTagNames);68 assert_equals(instance1.localName, 'custom-element-1');69 assert_equals(instance1.nodeName, 'CUSTOM-ELEMENT-1');70 71 var instance2 = new ElementWithMultipleTagNames('custom-element-2');72 assert_true(instance2 instanceof ElementWithMultipleTagNames);73 assert_equals(instance2.localName, 'custom-element-2');74 assert_equals(instance2.nodeName, 'CUSTOM-ELEMENT-2');75 76 assert_throws({'name': 'TypeError'}, function () { new ElementWithMultipleTagNames; },77 'Instantiating an element interface associated with multiple tag names without specifying the tag name must throw TypeError');78 79 }, 'HTMLElement constructor must allow associating an element interface with multiple tag names');80 81 test(function () {82 47 class ConcreteCustomElement extends HTMLElement { }; 83 48 class SubCustomElement extends ConcreteCustomElement { }; 84 document.defineCustomElement('concrete-custom-element', ConcreteCustomElement); 85 document.defineCustomElement('sub-custom-element', SubCustomElement); 49 document.defineElement('concrete-custom-element', ConcreteCustomElement); 50 document.defineElement('sub-custom-element', SubCustomElement); 51 52 var instance = new ConcreteCustomElement(); 53 assert_true(instance instanceof ConcreteCustomElement); 54 assert_false(instance instanceof SubCustomElement); 55 assert_equals(instance.localName, 'concrete-custom-element'); 56 assert_equals(instance.nodeName, 'CONCRETE-CUSTOM-ELEMENT'); 86 57 87 58 var instance = new SubCustomElement(); 59 assert_true(instance instanceof ConcreteCustomElement); 88 60 assert_true(instance instanceof SubCustomElement); 89 61 assert_equals(instance.localName, 'sub-custom-element'); … … 95 67 class AbstractCustomElement extends HTMLElement { }; 96 68 class ConcreteSubCustomElement extends AbstractCustomElement { }; 97 document.define CustomElement('concrete-sub-custom-element', ConcreteSubCustomElement);69 document.defineElement('concrete-sub-custom-element', ConcreteSubCustomElement); 98 70 99 71 var instance = new ConcreteSubCustomElement(); 72 assert_true(instance instanceof AbstractCustomElement); 100 73 assert_true(instance instanceof ConcreteSubCustomElement); 101 74 assert_equals(instance.localName, 'concrete-sub-custom-element'); -
trunk/LayoutTests/fast/custom-elements/parser/parser-constructs-custom-element-in-document-write.html
r197528 r197602 14 14 15 15 class MyCustomElement extends HTMLElement { } 16 document.define CustomElement('my-custom-element', MyCustomElement);16 document.defineElement('my-custom-element', MyCustomElement); 17 17 18 18 document.write('<my-custom-element></my-custom-element>'); -
trunk/LayoutTests/fast/custom-elements/parser/parser-constructs-custom-element-synchronously.html
r197466 r197602 25 25 } 26 26 }; 27 document.define CustomElement('my-custom-element', MyCustomElement);27 document.defineElement('my-custom-element', MyCustomElement); 28 28 29 29 </script> -
trunk/LayoutTests/fast/custom-elements/parser/parser-constructs-custom-elements.html
r197463 r197602 26 26 }, 'HTML parser must NOT create a custom element before defineElement is called'); 27 27 28 document.define CustomElement('my-custom-element', MyCustomElement);28 document.defineElement('my-custom-element', MyCustomElement); 29 29 30 30 </script> -
trunk/LayoutTests/fast/custom-elements/parser/parser-fallsback-to-unknown-element.html
r197463 r197602 19 19 } 20 20 }; 21 document.define CustomElement('returns-text', ReturnsTextNode);21 document.defineElement('returns-text', ReturnsTextNode); 22 22 23 23 class ReturnsNonElementObject extends HTMLElement { … … 27 27 } 28 28 }; 29 document.define CustomElement('returns-non-element-object', ReturnsNonElementObject);29 document.defineElement('returns-non-element-object', ReturnsNonElementObject); 30 30 31 31 class LacksSuperCall extends HTMLElement { 32 32 constructor() { } 33 33 }; 34 document.define CustomElement('lacks-super-call', LacksSuperCall);34 document.defineElement('lacks-super-call', LacksSuperCall); 35 35 36 36 class ThrowsException extends HTMLElement { … … 39 39 } 40 40 }; 41 document.define CustomElement('throws-exception', ThrowsException);41 document.defineElement('throws-exception', ThrowsException); 42 42 43 43 </script> -
trunk/LayoutTests/fast/custom-elements/parser/parser-sets-attributes-and-children.html
r197463 r197602 23 23 } 24 24 }; 25 document.define CustomElement('my-custom-element', MyCustomElement);25 document.defineElement('my-custom-element', MyCustomElement); 26 26 27 27 </script> -
trunk/LayoutTests/fast/custom-elements/parser/parser-uses-constructed-element.html
r197463 r197602 26 26 } 27 27 }; 28 document.define CustomElement('instantiates-itself-before-super', InstantiatesItselfBeforeSuper);28 document.defineElement('instantiates-itself-before-super', InstantiatesItselfBeforeSuper); 29 29 30 30 let shouldCreateAnotherInstance = true; … … 43 43 } 44 44 }; 45 document.define CustomElement('returns-another-instance', ReturnsAnotherInstance);45 document.defineElement('returns-another-instance', ReturnsAnotherInstance); 46 46 47 47 </script> -
trunk/LayoutTests/fast/custom-elements/parser/parser-uses-registry-of-owner-document.html
r197528 r197602 14 14 15 15 class MyCustomElement extends HTMLElement { }; 16 document.define CustomElement('my-custom-element', MyCustomElement);16 document.defineElement('my-custom-element', MyCustomElement); 17 17 18 18 document.write('<template><my-custom-element></my-custom-element></template>'); … … 44 44 45 45 class ElementInIFrame extends iframe.contentWindow.HTMLElement { }; 46 iframe.contentDocument.define CustomElement('element-in-iframe', ElementInIFrame);46 iframe.contentDocument.defineElement('element-in-iframe', ElementInIFrame); 47 47 iframe.contentDocument.body.innerHTML = '<element-in-iframe></element-in-iframe>'; 48 48 -
trunk/Source/WebCore/ChangeLog
r197600 r197602 1 2016-03-04 Ryosuke Niwa <rniwa@webkit.org> 2 3 Update defineCustomElement according to the spec rewrite 4 https://bugs.webkit.org/show_bug.cgi?id=155010 5 <rdar://problem/24970878> 6 7 Reviewed by Chris Dumez. 8 9 Updated the implementation of defineCustomElement and HTMLConstructor per recent rewrite of the spec: 10 https://w3c.github.io/webcomponents/spec/custom/#dom-document-defineelement 11 https://w3c.github.io/webcomponents/spec/custom/#htmlelement-constructor 12 13 defineCustomElement is now called defineElement and we disallow defining multiple custom elements with 14 a single class and throw an exception in defineElement. 15 16 Test: fast/custom-elements/Document-defineElement.html 17 18 * bindings/js/JSDocumentCustom.cpp: 19 (WebCore::JSDocument::defineElement): Renamed from defineCustomElement. Throw an exception when the interface 20 already defines another custom element. Also added FIXME's for missing steps. 21 22 * bindings/js/JSHTMLElementCustom.cpp: 23 (WebCore::constructJSHTMLElement): Removed the support for specifying a tag name in the first argument when 24 a single class defines multiple custom elements since that now results in an exception (in defineElement). 25 26 * dom/CustomElementDefinitions.cpp: 27 (WebCore::CustomElementDefinitions::containsConstructor): Added. 28 * dom/CustomElementDefinitions.h: 29 * dom/Document.idl: Renamed defineCustomElement to defineElement. 30 * html/HTMLElement.idl: Removed the optional tag name from the constructor. 31 1 32 2016-03-04 Tim Horton <timothy_horton@apple.com> 2 33 -
trunk/Source/WebCore/bindings/js/JSDocumentCustom.cpp
r197528 r197602 136 136 137 137 #if ENABLE(CUSTOM_ELEMENTS) 138 JSValue JSDocument::define CustomElement(ExecState& state)138 JSValue JSDocument::defineElement(ExecState& state) 139 139 { 140 140 AtomicString tagName(state.argument(0).toString(&state)->toAtomicString(&state)); … … 164 164 } 165 165 166 QualifiedName name(nullAtom, tagName, HTMLNames::xhtmlNamespaceURI);167 166 auto& definitions = document.ensureCustomElementDefinitions(); 168 167 if (definitions.findInterface(tagName)) { … … 170 169 return jsUndefined(); 171 170 } 171 172 if (definitions.containsConstructor(object)) { 173 throwNotSupportedError(state, "Cannot define multiple custom elements with the same class"); 174 return jsUndefined(); 175 } 176 177 // FIXME: 10. Let prototype be Get(constructor, "prototype"). Rethrow any exceptions. 178 // FIXME: 11. If Type(prototype) is not Object, throw a TypeError exception. 179 // FIXME: 12. Let attachedCallback be Get(prototype, "attachedCallback"). Rethrow any exceptions. 180 // FIXME: 13. Let detachedCallback be Get(prototype, "detachedCallback"). Rethrow any exceptions. 181 // FIXME: 14. Let attributeChangedCallback be Get(prototype, "attributeChangedCallback"). Rethrow any exceptions. 182 183 QualifiedName name(nullAtom, tagName, HTMLNames::xhtmlNamespaceURI); 172 184 definitions.defineElement(name, JSCustomElementInterface::create(object, globalObject())); 173 185 PrivateName uniquePrivateName; 174 186 globalObject()->putDirect(globalObject()->vm(), uniquePrivateName, object); 187 188 // FIXME: 17. Let map be registry's upgrade candidates map. 189 // FIXME: 18. Upgrade a newly-defined element given map and definition. 175 190 176 191 return jsUndefined(); -
trunk/Source/WebCore/bindings/js/JSHTMLElementCustom.cpp
r195087 r197602 55 55 JSObject* newTarget = newTargetValue.getObject(); 56 56 QualifiedName fullName = definitions->findName(newTarget); 57 if (fullName == nullQName()) { 58 if (UNLIKELY(state->argumentCount() < 1)) 59 return throwVMError(state, createNotEnoughArgumentsError(state)); 60 } 61 62 if (state->argumentCount()) { 63 String name; 64 if (!state->argument(0).getString(state, name)) 65 return throwVMTypeError(state, "The first argument is not a valid custom element name"); 66 67 auto* interface = definitions->findInterface(name); 68 if (!interface) 69 return throwVMTypeError(state, "The first argument is not a valid custom element name"); 70 71 if (newTarget != interface->constructor()) 72 return throwVMTypeError(state, "Attempt to construct a custom element with a wrong interface"); 73 74 fullName = QualifiedName(nullAtom, name, HTMLNames::xhtmlNamespaceURI); 75 } 57 if (fullName == nullQName()) 58 return throwVMTypeError(state, "new.target does not define a custom element"); 76 59 77 60 auto* globalObject = jsConstructor->globalObject(); -
trunk/Source/WebCore/dom/CustomElementDefinitions.cpp
r195538 r197602 95 95 } 96 96 97 bool CustomElementDefinitions::containsConstructor(const JSC::JSObject* constructor) const 98 { 99 return m_constructorMap.contains(constructor); 100 } 101 97 102 const QualifiedName& CustomElementDefinitions::findName(const JSC::JSObject* constructor) const 98 103 { -
trunk/Source/WebCore/dom/CustomElementDefinitions.h
r195538 r197602 53 53 JSCustomElementInterface* findInterface(const QualifiedName&) const; 54 54 JSCustomElementInterface* findInterface(const AtomicString&) const; 55 bool containsConstructor(const JSC::JSObject*) const; 55 56 const QualifiedName& findName(const JSC::JSObject*) const; 56 57 -
trunk/Source/WebCore/dom/Document.idl
r197353 r197602 296 296 #if defined(LANGUAGE_JAVASCRIPT) && LANGUAGE_JAVASCRIPT 297 297 [Custom, RaisesException, Conditional=CUSTOM_ELEMENTS] 298 void define CustomElement(DOMString tagName, CustomElementInterface elementInterface);298 void defineElement(DOMString localName, Function constructor); 299 299 #endif 300 300 -
trunk/Source/WebCore/html/HTMLElement.idl
r197353 r197602 21 21 [ 22 22 #if defined(ENABLE_CUSTOM_ELEMENTS) && ENABLE_CUSTOM_ELEMENTS 23 CustomConstructor( optional DOMString localName),23 CustomConstructor(), 24 24 #endif 25 25 JSGenerateToNativeObject,
Note: See TracChangeset
for help on using the changeset viewer.