|
2 | 2 | <html>
|
3 | 3 | <head lang="en">
|
4 | 4 | <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> |
6 | 6 | <title>Testing jquery object identities</title>
|
7 | 7 | </head>
|
8 | 8 | <body>
|
@@ -52,6 +52,46 @@ <h1>Testing jquery object identities</h1>
|
52 | 52 |
|
53 | 53 | console.log($b.text());
|
54 | 54 |
|
| 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 | + |
55 | 95 | });
|
56 | 96 | </script>
|
57 | 97 | </body>
|
|
0 commit comments