From 13e9e3e9e8633c7a54fe5fec1481e9df62594982 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Sat, 16 Nov 2019 18:23:43 +0100 Subject: treewide: fix "Unhandled token" errors with Lua CBI maps The `data-type` attribute is used to bind datatype validators to a widget while some templates used the same attribute to denote the name of the underlying widget. Change the `data-type` attributes referring to the widget name to `data-widget` in order to stop the JS token error spam. Signed-off-by: Jo-Philipp Wich --- modules/luci-base/htdocs/luci-static/resources/form.js | 10 +++++----- modules/luci-compat/luasrc/view/cbi/cell_valueheader.htm | 2 +- modules/luci-compat/luasrc/view/cbi/tblsection.htm | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'modules') diff --git a/modules/luci-base/htdocs/luci-static/resources/form.js b/modules/luci-base/htdocs/luci-static/resources/form.js index 7de5e0f76b..1c6f843041 100644 --- a/modules/luci-base/htdocs/luci-static/resources/form.js +++ b/modules/luci-base/htdocs/luci-static/resources/form.js @@ -1103,7 +1103,7 @@ var CBITableSection = CBITypedSection.extend({ trEl.appendChild(E('div', { 'class': 'th cbi-section-table-cell', - 'data-type': opt.__name__ + 'data-widget': opt.__name__ })); if (opt.width != null) @@ -1139,7 +1139,7 @@ var CBITableSection = CBITypedSection.extend({ trEl.appendChild(E('div', { 'class': 'th cbi-section-table-cell', - 'data-type': opt.__name__ + 'data-widget': opt.__name__ }, opt.description)); if (opt.width != null) @@ -1444,7 +1444,7 @@ var CBIGridSection = CBITableSection.extend({ 'data-title': (title != '') ? title : null, 'data-description': (descr != '') ? descr : null, 'data-name': opt.option, - 'data-type': opt.typename || opt.__name__ + 'data-widget': opt.typename || opt.__name__ }, (value != null) ? value : E('em', _('none'))); }, @@ -1586,7 +1586,7 @@ var CBIValue = CBIAbstractValue.extend({ 'data-title': (title != '') ? title : null, 'data-description': this.stripTags(this.description).trim(), 'data-name': this.option, - 'data-type': this.typename || (this.template ? this.template.replace(/^.+\//, '') : null) || this.__name__ + 'data-widget': this.typename || (this.template ? this.template.replace(/^.+\//, '') : null) || this.__name__ }, E('div', { 'id': 'cbi-%s-%s-%s'.format(config_name, section_id, this.option), 'data-index': option_index, @@ -1602,7 +1602,7 @@ var CBIValue = CBIAbstractValue.extend({ 'data-depends': depend_list, 'data-field': this.cbid(section_id), 'data-name': this.option, - 'data-type': this.typename || (this.template ? this.template.replace(/^.+\//, '') : null) || this.__name__ + 'data-widget': this.typename || (this.template ? this.template.replace(/^.+\//, '') : null) || this.__name__ }); if (this.last_child) diff --git a/modules/luci-compat/luasrc/view/cbi/cell_valueheader.htm b/modules/luci-compat/luasrc/view/cbi/cell_valueheader.htm index 4b70957543..db5c66850d 100644 --- a/modules/luci-compat/luasrc/view/cbi/cell_valueheader.htm +++ b/modules/luci-compat/luasrc/view/cbi/cell_valueheader.htm @@ -5,7 +5,7 @@ -%>
0, "data-type", ftype) .. + ifattr(ftype and #ftype > 0, "data-widget", ftype) .. ifattr(title and #title > 0, "data-title", title, true) .. ifattr(descr and #descr > 0, "data-description", descr, true) %>> diff --git a/modules/luci-compat/luasrc/view/cbi/tblsection.htm b/modules/luci-compat/luasrc/view/cbi/tblsection.htm index 11c2206d8c..1e067edf38 100644 --- a/modules/luci-compat/luasrc/view/cbi/tblsection.htm +++ b/modules/luci-compat/luasrc/view/cbi/tblsection.htm @@ -52,7 +52,7 @@ function render_titles() for i, k in ipairs(self.children) do if not k.optional then %>