]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Fix "unique notice form ID" code for reply forms
authorMikael Nordfeldth <mmn@hethane.se>
Mon, 6 Apr 2015 15:35:29 +0000 (17:35 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Mon, 6 Apr 2015 15:35:29 +0000 (17:35 +0200)
js/util.js

index 0bda55b602d9cda95dbf832dc3f6b0db491b3812..190c1e4f43647724d313ddc417cce8851bcc7bff 100644 (file)
@@ -224,7 +224,16 @@ var SN = { // StatusNet
             var newId = 'form_notice_' + Math.floor(Math.random()*999999999);
             var attrs = ['name', 'for', 'id'];
             for (var key in attrs) {
-                form.find("[" + attrs[key] + "~='" + oldId + "']").each(function () {
+                if (form.attr(attrs[key]) === undefined) {
+                    continue;
+                }
+                form.attr(attrs[key], form.attr(attrs[key]).replace(oldId, newId));
+            }
+            for (var key in attrs) {
+                form.find("[" + attrs[key] + "*='" + oldId + "']").each(function () {
+                        if ($(this).attr(attrs[key]) === undefined) {
+                            return; // since we're inside the each(function () { ... });
+                        }
                         var newAttr = $(this).attr(attrs[key]).replace(oldId, newId);
                         $(this).attr(attrs[key], newAttr);
                     });