diff --git a/Resources/jquerytest.html b/Resources/jquerytest.html index 09e87e3..1fd42e2 100644 --- a/Resources/jquerytest.html +++ b/Resources/jquerytest.html @@ -2,7 +2,7 @@ - + Testing jquery object identities @@ -52,6 +52,46 @@

Testing jquery object identities

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 = $('
').appendTo($('body')); + var $p = $('

'); + var $testNode = $(''); + $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 = $('

').appendTo($('body')); + $p = $('

'); + $testNode = $(''); + $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()); + });