Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(699)

Unified Diff: src/com/google/caja/plugin/html-emitter.js

Issue 89076: fix some html-emitter problems on IE (Closed) Base URL: http://google-caja.googlecode.com/svn/trunk/
Patch Set: fix some html-emitter problems on IE Created 14 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/com/google/caja/plugin/domita_test_untrusted.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/com/google/caja/plugin/html-emitter.js
===================================================================
--- src/com/google/caja/plugin/html-emitter.js (revision 3649)
+++ src/com/google/caja/plugin/html-emitter.js (working copy)
@@ -40,7 +40,8 @@
idMap = {};
var descs = base.getElementsByTagName('*');
for (var i = 0, desc; (desc = descs[i]); ++i) {
- if (desc.id) { idMap[desc.id] = desc; }
+ var id = desc.getAttribute('id');
+ if (id) { idMap[id] = desc; }
}
}
/**
@@ -180,11 +181,16 @@
}
// Reattach up to and including limit ancestor.
var nConsumed = 0;
- while (true) {
- var toReattach = detached[nConsumed];
- (detached[nConsumed + 1] /* the parent */).appendChild(toReattach);
+ while (nConsumed < detached.length) {
MikeSamuel 2009/08/11 22:52:28 Why does this condition change?
felix8a 2009/08/12 08:05:17 last-ditch recovery in case we walk off the end of
MikeSamuel 2009/08/12 16:17:29 Fair enough. Please comment the condition so that
+ // in IE, some types of nodes can't be standalone, and detaching
+ // one will create new parentNodes for them. so at this point,
+ // limitAnc might be an ancestor of the node on detached.
+ var reattach = detached[nConsumed];
+ var reattAnc = reattach;
+ for (; reattAnc.parentNode; reattAnc = reattAnc.parentNode) {}
+ (detached[nConsumed + 1] /* the parent */).appendChild(reattach);
nConsumed += 2;
- if (toReattach === limitAnc) { break; }
+ if (reattAnc === limitAnc) { break; }
}
// Replace the reattached bits with the ones detached from limit.
newDetached[1] = nConsumed; // splice's second arg is the number removed
« no previous file with comments | « no previous file | tests/com/google/caja/plugin/domita_test_untrusted.html » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b