From: Jo-Philipp Wich Date: Wed, 17 Oct 2018 05:43:54 +0000 (+0200) Subject: luci-base: fix cbi dropdown quirks with MS Edge X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=f1a5b179dd6f0d1cf91a47f4e7ff13759de9cf8f;p=oweals%2Fluci.git 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 (cherry picked from commit 9e6949849d7a34d17a7e43c79038f26a9b98d879) --- diff --git a/modules/luci-base/htdocs/luci-static/resources/cbi.js b/modules/luci-base/htdocs/luci-static/resources/cbi.js index fcfc50694..47501bd47 100644 --- a/modules/luci-base/htdocs/luci-static/resources/cbi.js +++ b/modules/luci-base/htdocs/luci-static/resources/cbi.js @@ -1801,7 +1801,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 })); }); @@ -1840,7 +1840,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; }); @@ -1851,7 +1851,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)); @@ -1926,7 +1926,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 cf8c03d22..6f4b89905 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 3a108020b..16d8af3d0 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 a97e9ef6d..55a7e3168 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:%>