Reviewers: felix8a,
Please review this at http://codereview.appspot.com/132054
Affected files:
M src/com/google/caja/plugin/html-emitter.js
M src/com/google/caja/util/Sets.java
Index: src/com/google/caja/plugin/html-emitter.js
===================================================================
--- src/com/google/caja/plugin/html-emitter.js (revision 3803)
+++ src/com/google/caja/plugin/html-emitter.js (working copy)
@@ -24,7 +24,7 @@
*
* @author [email protected]
* @provides HtmlEmitter
- * @requires bridal
+ * @requires bridal html html4 ___
*/
/**
@@ -296,6 +296,8 @@
return;
}
tameDoc.sanitizeAttrs___(tagName, attribs);
+ // TODO(mikesamuel): use the insertionPoint's ownerDocument
+ // to create the element.
var el = bridal.createElement(tagName, attribs);
if ((eltype & html4.eflags.OPTIONAL_ENDTAG)
&& el.tagName === insertionPoint.tagName) {
@@ -317,11 +319,12 @@
}
},
pcdata: function (text) {
- insertionPoint.appendChild(
- document.createTextNode(html.unescapeEntities(text)));
+
insertionPoint.appendChild(insertionPoint.ownerDocument.createTextNode(
+ html.unescapeEntities(text)));
},
cdata: function (text) {
- insertionPoint.appendChild(document.createTextNode(text));
+ insertionPoint.appendChild(
+ insertionPoint.ownerDocument.createTextNode(text));
}
};
documentWriter.rcdata = documentWriter.pcdata;
@@ -342,7 +345,7 @@
/**
* A tame version of document.write.
* @param html_varargs according to HTML5, the input to document.write
is
- * an varargs, and the HTML is the concatenation of all the
arguments.
+ * varargs, and the HTML is the concatenation of all the arguments.
*/
var tameDocWrite = function write(html_varargs) {
var htmlText = concat(arguments);
@@ -350,7 +353,7 @@
// Handles case 3 where the document has been closed.
insertionPoint = base;
}
- var lexer = html.makeSaxParser(documentWriter);
+ var lexer = html.makeSaxParser(documentWriter);
lexer(htmlText);
};
tameDoc.write = ___.markFuncFreeze(tameDocWrite, 'write');
Index: src/com/google/caja/util/Sets.java
===================================================================
--- src/com/google/caja/util/Sets.java (revision 3803)
+++ src/com/google/caja/util/Sets.java (working copy)
@@ -143,7 +143,7 @@
/** <tt>a U b</tt> */
public static <T> Set<T> union(
Collection<? extends T> a, Collection<? extends T> b) {
- Set<T> u = new LinkedHashSet<T>(a);
+ Set<T> u = newLinkedHashSet(a);
u.addAll(b);
return u;
}
@@ -156,7 +156,7 @@
a = b;
b = t;
}
- Set<T> i = new LinkedHashSet<T>(b);
+ Set<T> i = newLinkedHashSet(b);
i.retainAll(a);
return i;
}
@@ -164,7 +164,7 @@
/** <tt>(pos - neg)</tt>. */
public static <T> Set<T> difference(
Collection<? extends T> pos, Collection<? extends T> neg) {
- Set<T> d = new LinkedHashSet<T>(pos);
+ Set<T> d = newLinkedHashSet(pos);
d.removeAll(neg);
return d;
}