From 07d92acfd03752681d6624aac560b75f4eebc7c1 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Mon, 6 Apr 2015 17:35:29 +0200 Subject: [PATCH] Fix "unique notice form ID" code for reply forms --- js/util.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/js/util.js b/js/util.js index 0bda55b602..190c1e4f43 100644 --- a/js/util.js +++ b/js/util.js @@ -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); }); -- 2.39.5