From 9e6949849d7a34d17a7e43c79038f26a9b98d879 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 17 Oct 2018 07:43:54 +0200 Subject: [PATCH] luci-base: fix cbi dropdown quirks with MS Edge On MS Edge, the behaviour of "value" attributes on "li" elements is unreliable, so use the "data-" prefix to circumvent the problem. Ref: https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/19320991/ Fixes: #2224 Signed-off-by: Jo-Philipp Wich --- .../luci-base/htdocs/luci-static/resources/cbi.js | 8 ++++---- modules/luci-base/luasrc/view/cbi/dropdown.htm | 2 +- .../luci-base/luasrc/view/cbi/firewall_zonelist.htm | 12 ++++++------ .../luci-base/luasrc/view/cbi/network_ifacelist.htm | 6 +++--- .../luci-base/luasrc/view/cbi/network_netlist.htm | 8 ++++---- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js index 70255c0b58..f4bf0f40fa 100644 --- a/modules/luci-base/htdocs/luci-static/resources/cbi.js +++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js @@ -1774,7 +1774,7 @@ CBIDropdown = { div.appendChild(E('input', { type: 'hidden', name: s.hasAttribute('name') ? s.getAttribute('name') : (sb.getAttribute('name') || ''), - value: s.hasAttribute('value') ? s.getAttribute('value') : s.innerText + value: s.hasAttribute('data-value') ? s.getAttribute('data-value') : s.innerText })); }); @@ -1813,7 +1813,7 @@ CBIDropdown = { var new_item = null; ul.childNodes.forEach(function(li) { - if (li.getAttribute && li.getAttribute('value') === item) + if (li.getAttribute && li.getAttribute('data-value') === item) new_item = li; }); @@ -1824,7 +1824,7 @@ CBIDropdown = { if (tpl) markup = (tpl.textContent || tpl.innerHTML || tpl.firstChild.data).replace(/^$/, '').trim(); else - markup = '
  • {{value}}
  • '; + markup = '
  • {{value}}
  • '; new_item = E(markup.replace(/{{value}}/g, item)); @@ -1899,7 +1899,7 @@ function cbi_dropdown_init(sb) { ndisplay--; - if (this.optional && !ul.querySelector('li[value=""]')) { + if (this.optional && !ul.querySelector('li[data-value=""]')) { var placeholder = E('li', { placeholder: '' }, this.placeholder); ul.firstChild ? ul.insertBefore(placeholder, ul.firstChild) : ul.appendChild(placeholder); } diff --git a/modules/luci-base/luasrc/view/cbi/dropdown.htm b/modules/luci-base/luasrc/view/cbi/dropdown.htm index cf8c03d22c..6f4b89905b 100644 --- a/modules/luci-base/luasrc/view/cbi/dropdown.htm +++ b/modules/luci-base/luasrc/view/cbi/dropdown.htm @@ -30,7 +30,7 @@ > <%=pcdata(self.vallist[i])%> diff --git a/modules/luci-base/luasrc/view/cbi/firewall_zonelist.htm b/modules/luci-base/luasrc/view/cbi/firewall_zonelist.htm index c5addc0ddb..7ecec10a8f 100644 --- a/modules/luci-base/luasrc/view/cbi/firewall_zonelist.htm +++ b/modules/luci-base/luasrc/view/cbi/firewall_zonelist.htm @@ -30,7 +30,7 @@ ifattr(self.rmempty or self.optional, "optional", "optional") %>>
      <% if self.allowlocal then %> -
    • > +
    • > <%:Device%> <% if self.allowany and self.allowlocal then -%> @@ -48,14 +48,14 @@
    • <% elseif self.widget ~= "checkbox" and (self.rmempty or self.optional) then %> -
    • > +
    • > <%:unspecified%>
    • <% end %> <% if self.allowany then %> -
    • > +
    • > <%:Any zone%> <% if self.allowany and self.allowlocal then %>(<%:forward%>)<% end %> @@ -67,7 +67,7 @@ if zone:name() ~= self.exclude then selected = selected or (value == zone:name()) %> - > + > <%=zone:name()%>: <%- @@ -94,7 +94,7 @@ <% end end %> <% if self.widget ~= "checkbox" and not self.nocreate then %> -
    • +
    • <%:create%>: diff --git a/modules/luci-base/luasrc/view/cbi/network_ifacelist.htm b/modules/luci-base/luasrc/view/cbi/network_ifacelist.htm index a97e9ef6d0..55a7e31687 100644 --- a/modules/luci-base/luasrc/view/cbi/network_ifacelist.htm +++ b/modules/luci-base/luasrc/view/cbi/network_ifacelist.htm @@ -47,7 +47,7 @@ ifattr(self.widget == "checkbox", "optional", "optional") %>>
        <% if self.widget ~= "checkbox" then %> -
      • > +
      • > <%:unspecified%>
      • <% end %> @@ -44,7 +44,7 @@ (net:name() ~= self.exclude) and (not self.novirtual or not net:is_virtual()) then %> - > + > <%=net:name()%>: <% local empty = true @@ -63,7 +63,7 @@ <% end end %> <% if not self.nocreate then %> -
      • > +
      • > <%- if self.widget == "checkbox" then -%> <%:create:%> -- 2.30.2