Changeset 205220 in webkit
- Timestamp:
- Aug 30, 2016 10:18:54 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r205219 r205220 1 2016-08-30 Ryosuke Niwa <rniwa@webkit.org> 2 3 Add "get" to CustomElementsRegistry 4 https://bugs.webkit.org/show_bug.cgi?id=161421 5 6 Reviewed by Yusuke Suzuki. 7 8 Added test cases for "get" method on CustomElementsRegistry. 9 10 * fast/custom-elements/CustomElementRegistry-expected.txt: 11 * fast/custom-elements/CustomElementRegistry.html: 12 1 13 2016-08-30 Jiewen Tan <jiewen_tan@apple.com> 2 14 -
trunk/LayoutTests/fast/custom-elements/CustomElementRegistry-expected.txt
r204732 r205220 18 18 PASS customElements.define must not throw even if "observedAttributes" fails to convert if "attributeChangedCallback" is not defined 19 19 PASS customElements.define must define an instantiatable custom element 20 PASS CustomElementRegistry interface must have get as a method 21 PASS "get" must return undefined when the registry does not contain an entry with the given name 22 PASS "get" must return undefined when the registry does not contain an entry with the given name even if the name was not a valid custom element name 23 PASS "get" return the constructor of the entry with the given name when there is a matching entry. 20 24 -
trunk/LayoutTests/fast/custom-elements/CustomElementRegistry.html
r204732 r205220 268 268 }, 'customElements.define must define an instantiatable custom element'); 269 269 270 test(function () { 271 assert_true('get' in CustomElementRegistry.prototype, '"get" exists on CustomElementRegistry.prototype'); 272 assert_true('get' in customElements, '"get" exists on window.customElements'); 273 }, 'CustomElementRegistry interface must have get as a method'); 274 275 test(function () { 276 assert_equals(customElements.get('a-b'), undefined); 277 }, '"get" must return undefined when the registry does not contain an entry with the given name'); 278 279 test(function () { 280 assert_equals(customElements.get('html'), undefined); 281 assert_equals(customElements.get('span'), undefined); 282 assert_equals(customElements.get('div'), undefined); 283 assert_equals(customElements.get('g'), undefined); 284 assert_equals(customElements.get('ab'), undefined); 285 }, '"get" must return undefined when the registry does not contain an entry with the given name even if the name was not a valid custom element name'); 286 287 test(function () { 288 assert_equals(customElements.get('existing-custom-element'), undefined); 289 class ExistingCustomElement extends HTMLElement {}; 290 customElements.define('existing-custom-element', ExistingCustomElement); 291 assert_equals(customElements.get('existing-custom-element'), ExistingCustomElement); 292 }, '"get" return the constructor of the entry with the given name when there is a matching entry.'); 293 270 294 </script> 271 295 </body> -
trunk/Source/WebCore/ChangeLog
r205218 r205220 1 2016-08-30 Ryosuke Niwa <rniwa@webkit.org> 2 3 Add "get" to CustomElementsRegistry 4 https://bugs.webkit.org/show_bug.cgi?id=161421 5 6 Reviewed by Yusuke Suzuki. 7 8 Add the support for "get" method on CustomElementsRegistry, which returns the constructor 9 of the custom element with the given name: 10 https://html.spec.whatwg.org/multipage/scripting.html#dom-customelementregistry-get 11 12 Tests: fast/custom-elements/CustomElementRegistry.html 13 14 * dom/CustomElementRegistry.cpp: 15 (WebCore::CustomElementRegistry::get): Added. 16 * dom/CustomElementRegistry.h: 17 * dom/CustomElementRegistry.idl: 18 1 19 2016-08-30 Yusuke Suzuki <utatane.tea@gmail.com> 2 20 -
trunk/Source/WebCore/dom/CustomElementRegistry.cpp
r204732 r205220 106 106 } 107 107 108 JSC::JSValue CustomElementRegistry::get(const AtomicString& name) 109 { 110 if (auto* elementInterface = m_nameMap.get(name)) 111 return elementInterface->constructor(); 112 return JSC::jsUndefined(); 113 } 114 108 115 } 109 116 -
trunk/Source/WebCore/dom/CustomElementRegistry.h
r204732 r205220 36 36 37 37 class JSObject; 38 class JSValue; 38 39 39 40 } … … 58 59 bool containsConstructor(const JSC::JSObject*) const; 59 60 61 JSC::JSValue get(const AtomicString&); 62 60 63 private: 61 64 CustomElementRegistry(); … … 65 68 HashMap<const JSC::JSObject*, JSCustomElementInterface*> m_constructorMap; 66 69 }; 67 70 68 71 } 69 72 -
trunk/Source/WebCore/dom/CustomElementRegistry.idl
r204732 r205220 32 32 33 33 [CEReactions, Custom] void define(DOMString name, Function constructor); 34 any get(DOMString name); 34 35 35 36 };
Note: See TracChangeset
for help on using the changeset viewer.