Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

classList.remove can incorrectly trigger IE's onpropertychange event. #148

Open
GoogleCodeExporter opened this issue Jul 8, 2015 · 0 comments

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Using IE, add an onpropertychange event to a form control.
2. Use the classList.remove method to remove a non applied class.

What is the expected output? What do you see instead?
The onpropertychange event fires even though a class wasn't removed.

This can cause an infinite loop when the onpropertychange handler calls 
classList.remove.


Please provide any additional information below.
Patch for this issue:

--- src/base2/dom/html/ClassList.js     (revision 310)
+++ src/base2/dom/html/ClassList.js     (working copy)
@@ -16,8 +16,10 @@
   },

   remove: function(element, token) {
-    var regexp = new RegExp("(^|\\s)" + token + "(\\s|$)", "g");
-    element.className = trim(element.className.replace(regexp, "$2"));
+    if (ClassList.contains(element, token)) {
+      var regexp = new RegExp("(^|\\s)" + token + "(\\s|$)", "g");
+      element.className = trim(element.className.replace(regexp, "$2"));
+    }
   },

   toggle: function(element, token) {

Original issue reported on code.google.com by [email protected] on 1 May 2013 at 4:07

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant