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',