From 9b96e3cd30a8066811991d854ec0a9c30e8ed245 Mon Sep 17 00:00:00 2001 From: Victor Berchet Date: Wed, 20 Aug 2014 11:02:49 +0200 Subject: [PATCH] fix(web components): Fix tests in IE10 --- test/core_dom/web_components_support.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/test/core_dom/web_components_support.js b/test/core_dom/web_components_support.js index 4f09d1190..fee3a6a29 100644 --- a/test/core_dom/web_components_support.js +++ b/test/core_dom/web_components_support.js @@ -1,10 +1,18 @@ /** - * Used to create Javascript Web Components from Dart tests + * Registers Javascript Web Components from Dart tests. + * + * Per HTML5 spec, the prototype object should inherit from `HTMLELement`. + * see http://w3c.github.io/webcomponents/spec/custom/#extensions-to-document-interface-to-register + * + * Note: __proto__ can not be used as it is not supported in IE10. */ function angularTestsRegisterElement(name, prototype) { - // Polymer requires that all prototypes are chained to HTMLElement - // https://github.com/Polymer/CustomElements/issues/121 - prototype.__proto__ = HTMLElement.prototype; - prototype.createdCallback = function() {}; - document.registerElement(name, {prototype: prototype}); + var proto = Object.create(HTMLElement.prototype); + for (var p in prototype) { + if (prototype.hasOwnProperty(p)) { + proto[p] = prototype[p]; + } + } + proto.createdCallback = function() {}; + document.registerElement(name, {prototype: proto}); }