Skip to content
This repository was archived by the owner on Apr 22, 2020. It is now read-only.

Commit c3c6178

Browse files
author
mikesamuel@gmail.com
committed
fix problem with invented document fragments in number splitting in IE
1 parent a8823cf commit c3c6178

3 files changed

Lines changed: 12 additions & 7 deletions

File tree

js-modules/extractSourceSpans_test.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ <h1>Extract Source Spans Test</h1>
109109
}
110110
actual.innerHTML = '<pre>' + actualHtml + '<\/pre>';
111111
var goldenText = testResult.innerText || testResult.textContent;
112-
var goldenNormalized = '"' + goldenText + '"';
112+
var goldenNormalized = '"' + goldenText.replace(/(?:\r\n?|\n)$/, '') + '"';
113113
var actualNormalized = stringify(actualText);
114114
var passed = actualNormalized === goldenNormalized;
115115
if (!passed) {
@@ -125,5 +125,5 @@ <h1>Extract Source Spans Test</h1>
125125

126126
<hr>
127127
<address></address>
128-
<!-- hhmts start --> Last modified: Tue Mar 29 16:21:19 PDT 2011 <!-- hhmts end -->
128+
<!-- hhmts start --> Last modified: Tue Mar 29 16:38:23 PDT 2011 <!-- hhmts end -->
129129
</body> </html>

js-modules/numberLines.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,9 @@ function numberLines(node, opt_startLineNum) {
107107
var copiedListItem = breakLeftOf(lineEndNode.nextSibling, 0);
108108

109109
// Walk the parent chain until we reach an unattached LI.
110-
// Check nodeType since IE sticks useless document fragments around things.
111-
for (var parent; (parent = copiedListItem.parentNode) && parent.nodeType === 1;) {
110+
for (var parent;
111+
// Check nodeType since IE invents document fragments.
112+
(parent = copiedListItem.parentNode) && parent.nodeType === 1;) {
112113
copiedListItem = parent;
113114
}
114115
// Put it on the list of lines for later processing.

src/prettify.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -957,12 +957,16 @@ window['PR']
957957
return rightSide;
958958
}
959959

960-
var split = breakLeftOf(lineEndNode.nextSibling, 0);
960+
var copiedListItem = breakLeftOf(lineEndNode.nextSibling, 0);
961961

962962
// Walk the parent chain until we reach an unattached LI.
963-
for (var parent; (parent = split.parentNode);) { split = parent; }
963+
for (var parent;
964+
// Check nodeType since IE invents document fragments.
965+
(parent = copiedListItem.parentNode) && parent.nodeType === 1;) {
966+
copiedListItem = parent;
967+
}
964968
// Put it on the list of lines for later processing.
965-
listItems.push(split);
969+
listItems.push(copiedListItem);
966970
}
967971

968972
// Split lines while there are lines left to split.

0 commit comments

Comments
 (0)