Skip to content

Commit e36beb9

Browse files
committed
add test for setAttributeNS
1 parent 3d99ef3 commit e36beb9

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

packages/@simple-dom/document/test/element-test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,4 +308,28 @@ moduleWithDocument('Element', (helper) => {
308308

309309
});
310310

311+
QUnit.test('setAttributeNS', (assert) => {
312+
const svg = helper.document.createElementNS(Namespace.SVG, 'svg');
313+
314+
svg.setAttributeNS(Namespace.XMLNS, 'xmlns', 'http://www.w3.org/2000/svg');
315+
svg.setAttributeNS(Namespace.XMLNS, 'xmlns:xlink', 'http://www.w3.org/1999/xlink');
316+
317+
assert.equal(svg.attributes.length, 2);
318+
319+
assert.equal(svg.getAttributeNS(Namespace.XMLNS, 'xmlns'), 'http://www.w3.org/2000/svg');
320+
assert.equal(svg.getAttributeNS(Namespace.XMLNS, 'xlink'), 'http://www.w3.org/1999/xlink');
321+
322+
assert.strictEqual(svg.attributes[0].prefix, null);
323+
assert.equal(svg.attributes[0].localName, 'xmlns');
324+
assert.equal(svg.attributes[0].name, 'xmlns');
325+
assert.equal(svg.attributes[0].namespaceURI, Namespace.XMLNS);
326+
assert.equal(svg.attributes[0].value, 'http://www.w3.org/2000/svg');
327+
328+
assert.equal(svg.attributes[1].prefix, 'xmlns');
329+
assert.equal(svg.attributes[1].localName, 'xlink');
330+
assert.equal(svg.attributes[1].name, 'xmlns:xlink');
331+
assert.equal(svg.attributes[1].namespaceURI, Namespace.XMLNS);
332+
assert.equal(svg.attributes[1].value, 'http://www.w3.org/1999/xlink');
333+
});
334+
311335
});

0 commit comments

Comments
 (0)