Reviewers: ihab.awad,

Description:
Fixes <https://code.google.com/p/google-caja/issues/detail?id=1850>.

bridal.setAttribute used setAttributeNode to work around IE 6/7 quirks,
but (empirically) setAttributeNode cannot be used on IE 10 to set
<input type=>, so with IE 10 (and 9, per MSDN) no longer having
featureExtendedCreateElement, all such attributes are lost in ES5 mode.
Therefore, only use setAttributeNode if featureExtendedCreateElement
is present (even though that's technically unrelated).

This is a quick fix. More correct would be to detect the specific
misbehaviors which require us to use setAttributeNode.

Please review this at https://codereview.appspot.com/14061043/

Affected files (+10, -6 lines):
  M     src/com/google/caja/plugin/bridal.js


Index: src/com/google/caja/plugin/bridal.js
===================================================================
--- src/com/google/caja/plugin/bridal.js        (revision 5607)
+++ src/com/google/caja/plugin/bridal.js        (working copy)
@@ -525,13 +525,17 @@
         }
         break;
     }
-    try {
-      var attr = makeDOMAccessible(
+    if (featureExtendedCreateElement /* old IE, need workarounds */) {
+      try {
+        var attr = makeDOMAccessible(
           makeDOMAccessible(element.ownerDocument).createAttribute(name));
-      attr.value = value;
-      element.setAttributeNode(attr);
-    } catch (e) {
-      // It's a real failure only if setAttribute also fails.
+        attr.value = value;
+        element.setAttributeNode(attr);
+      } catch (e) {
+        // It's a real failure only if setAttribute also fails.
+        return element.setAttribute(name, value, 0);
+      }
+    } else {
       return element.setAttribute(name, value, 0);
     }
     return value;


--

--- You received this message because you are subscribed to the Google Groups "Google Caja Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to