Skip to content

Commit

Permalink
Testing behavior described in #33 in jQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
wasinger committed Jun 28, 2019
1 parent 8c00b18 commit 542f3f9
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion Resources/jquerytest.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html>
<head lang="en">
<meta charset="UTF-8">
<script src="//code.jquery.com/jquery-2.1.4.js"></script>
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<title>Testing jquery object identities</title>
</head>
<body>
Expand Down Expand Up @@ -52,6 +52,46 @@ <h1>Testing jquery object identities</h1>

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


// Test for issue #33 https://github.com/wasinger/htmlpagedom/issues/33
// Works like reporter expects in jquery but not in HmtlPageDom

var $rootNode = $('<div />').appendTo($('body'));
var $p = $('<p />');
var $testNode = $('<span />');
$testNode.text('incorrect text');
$p.append($testNode);
$rootNode.append($p);

// Change test node text after node appended
$testNode.text('correct text');

// Output root or parent node html. Incorrect in HtmlPageDom, Correct in jquery
console.log($rootNode.html());
console.log($p.html());

// Output node html. Correct
console.log($testNode.html());

// Second test: adding node to multiple nodes.
// If $testNode is appended to multple elements it doesn't work in jquery, either:
$rootNode = $('<div />').appendTo($('body'));
$p = $('<p /><p />');
$testNode = $('<span />');
$testNode.text('incorrect text');
$p.append($testNode);
$rootNode.append($p);

// Change test node text after node appended
$testNode.text('correct text');

// Output root or parent node html. Incorrect in jquery and HtmlPageDom
console.log($rootNode.html());
console.log($p.html());

// Output node html. Correct
console.log($testNode.html());

});
</script>
</body>
Expand Down

0 comments on commit 542f3f9

Please sign in to comment.