|
| 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 | +}); |
0 commit comments