simple-dom
Advanced tools
Comparing version 0.2.4 to 0.2.5
@@ -419,2 +419,6 @@ (function() { | ||
buffer += this.serialize(next); | ||
while(next = next.nextSibling) { | ||
buffer += this.serialize(next); | ||
} | ||
} | ||
@@ -426,7 +430,2 @@ | ||
next = node.nextSibling; | ||
if (next) { | ||
buffer += this.serialize(next); | ||
} | ||
return buffer; | ||
@@ -1279,13 +1278,43 @@ }; | ||
QUnit.test('serializes correctly', function (assert) { | ||
QUnit.test('serializes single element correctly', function (assert) { | ||
var actual = this.serializer.serialize($$support$$element('div')); | ||
assert.equal(actual, '<div></div>'); | ||
}); | ||
QUnit.test('serializes single void element correctly', function (assert) { | ||
var actual = this.serializer.serialize($$support$$element('img', { src: 'foo' })); | ||
assert.equal(actual, '<img src="foo">'); | ||
}); | ||
QUnit.test('serializes complex tree correctly', function (assert) { | ||
var actual = this.serializer.serialize($$support$$fragment( | ||
$$support$$element('div', { id:'foo' }, | ||
$$support$$element('div', { id: 'foo' }, | ||
$$support$$element('b', {}, | ||
$$support$$text('Foo & Bar') | ||
) | ||
), | ||
$$support$$text('!'), | ||
$$support$$element('img', { src: 'foo' }) | ||
) | ||
)); | ||
assert.equal(actual, '<div id="foo"><b>Foo & Bar</b></div>'); | ||
assert.equal(actual, '<div id="foo"><b>Foo & Bar</b>!<img src="foo"></div>'); | ||
}); | ||
QUnit.test('does not serialize siblings of an element', function (assert) { | ||
var html = $$support$$element('html'); | ||
var head = $$support$$element('head'); | ||
var body = $$support$$element('body'); | ||
head.appendChild($$support$$element('meta', { content: 'foo' })); | ||
head.appendChild($$support$$element('meta', { content: 'bar' })); | ||
html.appendChild(head); | ||
html.appendChild(body); | ||
var actual = this.serializer.serialize(head); | ||
assert.equal(actual, '<head><meta content="foo"><meta content="bar"></head>'); | ||
actual = this.serializer.serialize(body); | ||
assert.equal(actual, '<body></body>'); | ||
}); | ||
// SimpleDOM supports an extension of the DOM API that allows inserting strings of | ||
@@ -1292,0 +1321,0 @@ // unparsed, raw HTML into the document. When the document is subsequently serialized, |
@@ -485,2 +485,6 @@ (function() { | ||
buffer += this.serialize(next); | ||
while(next = next.nextSibling) { | ||
buffer += this.serialize(next); | ||
} | ||
} | ||
@@ -492,7 +496,2 @@ | ||
next = node.nextSibling; | ||
if (next) { | ||
buffer += this.serialize(next); | ||
} | ||
return buffer; | ||
@@ -499,0 +498,0 @@ }; |
@@ -96,2 +96,6 @@ function HTMLSerializer(voidMap) { | ||
buffer += this.serialize(next); | ||
while(next = next.nextSibling) { | ||
buffer += this.serialize(next); | ||
} | ||
} | ||
@@ -103,7 +107,2 @@ | ||
next = node.nextSibling; | ||
if (next) { | ||
buffer += this.serialize(next); | ||
} | ||
return buffer; | ||
@@ -110,0 +109,0 @@ }; |
{ | ||
"name": "simple-dom", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"description": "A simple JS DOM.", | ||
@@ -5,0 +5,0 @@ "main": "dist/simple-dom.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
300360
2023