Skip to content
This repository was archived by the owner on Mar 13, 2018. It is now read-only.

Commit a9ec396

Browse files
committed
Merge pull request #350 from arv/svg-tag-name
Fix issue with Element not having all the required properties
2 parents 42d24b8 + 309442d commit a9ec396

3 files changed

Lines changed: 59 additions & 1 deletion

File tree

src/wrappers/Element.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
mixin(Element.prototype, ParentNodeInterface);
127127
mixin(Element.prototype, SelectorsInterface);
128128

129-
registerWrapper(OriginalElement, Element);
129+
registerWrapper(OriginalElement, Element, document.createElement(null, 'x'));
130130

131131
// TODO(arv): Export setterDirtiesAttribute and apply it to more bindings
132132
// that reflect attributes.

test/js/SVGElement.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright 2014 The Polymer Authors. All rights reserved.
3+
* Use of this source code is goverened by a BSD-style
4+
* license that can be found in the LICENSE file.
5+
*/
6+
7+
suite('SVGElement', function() {
8+
9+
var SVG_NS = 'http://www.w3.org/2000/svg';
10+
11+
test('Basics', function() {
12+
var el = document.createElementNS(SVG_NS, 'svg');
13+
14+
assert.equal(el.localName, 'svg');
15+
assert.equal(el.tagName, 'svg');
16+
assert.equal(el.namespaceURI, SVG_NS);
17+
assert.instanceOf(el, SVGElement);
18+
assert.instanceOf(el, Element);
19+
assert.instanceOf(el, Node);
20+
assert.instanceOf(el, EventTarget);
21+
assert.notInstanceOf(el, HTMLElement);
22+
});
23+
24+
test('Basics innerHTML', function() {
25+
var div = document.createElement('div');
26+
div.innerHTML = '<svg></svg>';
27+
var el = div.firstChild;
28+
29+
assert.equal(el.localName, 'svg');
30+
assert.equal(el.tagName, 'svg');
31+
assert.equal(el.namespaceURI, SVG_NS);
32+
assert.instanceOf(el, SVGElement);
33+
assert.instanceOf(el, Element);
34+
assert.instanceOf(el, Node);
35+
assert.instanceOf(el, EventTarget);
36+
assert.notInstanceOf(el, HTMLElement);
37+
});
38+
39+
test('template', function() {
40+
var el = document.createElementNS(SVG_NS, 'template');
41+
42+
assert.equal(el.localName, 'template');
43+
assert.equal(el.tagName, 'template');
44+
assert.equal(el.namespaceURI, SVG_NS);
45+
46+
// IE does not create an SVGElement if the local name is not a known SVG
47+
// element.
48+
if (!/Trident/.test(navigator.userAgent))
49+
assert.instanceOf(el, SVGElement);
50+
51+
assert.instanceOf(el, Element);
52+
assert.instanceOf(el, Node);
53+
assert.instanceOf(el, EventTarget);
54+
assert.notInstanceOf(el, HTMLElement);
55+
});
56+
57+
});

test/test.main.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ var modules = [
110110
'Node.js',
111111
'ParentNodeInterface.js',
112112
'Range.js',
113+
'SVGElement.js',
113114
'SVGElementInstance.js',
114115
'ShadowRoot.js',
115116
'Text.js',

0 commit comments

Comments
 (0)