From 309442d57eb4be1a499a7068b52d598c53601c54 Mon Sep 17 00:00:00 2001 From: Erik Arvidsson Date: Wed, 15 Jan 2014 12:22:18 -0500 Subject: [PATCH] Fix issue with Element not having all the required properties --- src/wrappers/Element.js | 2 +- test/js/SVGElement.js | 57 +++++++++++++++++++++++++++++++++++++++++ test/test.main.js | 1 + 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 test/js/SVGElement.js diff --git a/src/wrappers/Element.js b/src/wrappers/Element.js index 4cc9331..ffb24ad 100644 --- a/src/wrappers/Element.js +++ b/src/wrappers/Element.js @@ -126,7 +126,7 @@ mixin(Element.prototype, ParentNodeInterface); mixin(Element.prototype, SelectorsInterface); - registerWrapper(OriginalElement, Element); + registerWrapper(OriginalElement, Element, document.createElement(null, 'x')); // TODO(arv): Export setterDirtiesAttribute and apply it to more bindings // that reflect attributes. diff --git a/test/js/SVGElement.js b/test/js/SVGElement.js new file mode 100644 index 0000000..0ca64e3 --- /dev/null +++ b/test/js/SVGElement.js @@ -0,0 +1,57 @@ +/* + * Copyright 2014 The Polymer Authors. All rights reserved. + * Use of this source code is goverened by a BSD-style + * license that can be found in the LICENSE file. + */ + +suite('SVGElement', function() { + + var SVG_NS = 'http://www.w3.org/2000/svg'; + + test('Basics', function() { + var el = document.createElementNS(SVG_NS, 'svg'); + + assert.equal(el.localName, 'svg'); + assert.equal(el.tagName, 'svg'); + assert.equal(el.namespaceURI, SVG_NS); + assert.instanceOf(el, SVGElement); + assert.instanceOf(el, Element); + assert.instanceOf(el, Node); + assert.instanceOf(el, EventTarget); + assert.notInstanceOf(el, HTMLElement); + }); + + test('Basics innerHTML', function() { + var div = document.createElement('div'); + div.innerHTML = ''; + var el = div.firstChild; + + assert.equal(el.localName, 'svg'); + assert.equal(el.tagName, 'svg'); + assert.equal(el.namespaceURI, SVG_NS); + assert.instanceOf(el, SVGElement); + assert.instanceOf(el, Element); + assert.instanceOf(el, Node); + assert.instanceOf(el, EventTarget); + assert.notInstanceOf(el, HTMLElement); + }); + + test('template', function() { + var el = document.createElementNS(SVG_NS, 'template'); + + assert.equal(el.localName, 'template'); + assert.equal(el.tagName, 'template'); + assert.equal(el.namespaceURI, SVG_NS); + + // IE does not create an SVGElement if the local name is not a known SVG + // element. + if (!/Trident/.test(navigator.userAgent)) + assert.instanceOf(el, SVGElement); + + assert.instanceOf(el, Element); + assert.instanceOf(el, Node); + assert.instanceOf(el, EventTarget); + assert.notInstanceOf(el, HTMLElement); + }); + +}); diff --git a/test/test.main.js b/test/test.main.js index 1e81ee6..49b685f 100644 --- a/test/test.main.js +++ b/test/test.main.js @@ -110,6 +110,7 @@ var modules = [ 'Node.js', 'ParentNodeInterface.js', 'Range.js', + 'SVGElement.js', 'SVGElementInstance.js', 'ShadowRoot.js', 'Text.js',