Skip to content

Commit 542f3f9

Browse files
author
wasinger
committed
Testing behavior described in #33 in jQuery
1 parent 8c00b18 commit 542f3f9

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

Resources/jquerytest.html

+41-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head lang="en">
44
<meta charset="UTF-8">
5-
<script src="//code.jquery.com/jquery-2.1.4.js"></script>
5+
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
66
<title>Testing jquery object identities</title>
77
</head>
88
<body>
@@ -52,6 +52,46 @@ <h1>Testing jquery object identities</h1>
5252

5353
console.log($b.text());
5454

55+
56+
// Test for issue #33 https://github.com/wasinger/htmlpagedom/issues/33
57+
// Works like reporter expects in jquery but not in HmtlPageDom
58+
59+
var $rootNode = $('<div />').appendTo($('body'));
60+
var $p = $('<p />');
61+
var $testNode = $('<span />');
62+
$testNode.text('incorrect text');
63+
$p.append($testNode);
64+
$rootNode.append($p);
65+
66+
// Change test node text after node appended
67+
$testNode.text('correct text');
68+
69+
// Output root or parent node html. Incorrect in HtmlPageDom, Correct in jquery
70+
console.log($rootNode.html());
71+
console.log($p.html());
72+
73+
// Output node html. Correct
74+
console.log($testNode.html());
75+
76+
// Second test: adding node to multiple nodes.
77+
// If $testNode is appended to multple elements it doesn't work in jquery, either:
78+
$rootNode = $('<div />').appendTo($('body'));
79+
$p = $('<p /><p />');
80+
$testNode = $('<span />');
81+
$testNode.text('incorrect text');
82+
$p.append($testNode);
83+
$rootNode.append($p);
84+
85+
// Change test node text after node appended
86+
$testNode.text('correct text');
87+
88+
// Output root or parent node html. Incorrect in jquery and HtmlPageDom
89+
console.log($rootNode.html());
90+
console.log($p.html());
91+
92+
// Output node html. Correct
93+
console.log($testNode.html());
94+
5595
});
5696
</script>
5797
</body>

0 commit comments

Comments
 (0)