diff --git a/src/taglibs/migrate/all-tags/widget-in-attrs.js b/src/taglibs/migrate/all-tags/widget-in-attrs.js index 01825a831..2564791e1 100644 --- a/src/taglibs/migrate/all-tags/widget-in-attrs.js +++ b/src/taglibs/migrate/all-tags/widget-in-attrs.js @@ -2,7 +2,11 @@ module.exports = function migrate(el, context) { el.forEachAttribute(attr => { const value = attr.value; - if (isWidgetElIdFunctionCall(value)) { + if ( + isWidgetElIdFunctionCall(value) && + el.tagName !== "var" && + el.tagName !== "assign" + ) { context.deprecate( `The "*=widget.elId("someId")" is deprecated. Please use "*:scoped="someId"" modifier instead. See: https://github.com/marko-js/marko/wiki/Deprecation:-w-*-Atrributes` ); diff --git a/test/migrate/fixtures/widget-in-attrs/snapshot-expected.marko b/test/migrate/fixtures/widget-in-attrs/snapshot-expected.marko index 2b09a2c23..415f13983 100644 --- a/test/migrate/fixtures/widget-in-attrs/snapshot-expected.marko +++ b/test/migrate/fixtures/widget-in-attrs/snapshot-expected.marko @@ -4,4 +4,6 @@
+$ var widgetId = component.elId(); $ var widgetId = a ? component.id : component.elId("b"); +$ widgetId = component.elId(); diff --git a/test/migrate/fixtures/widget-in-attrs/template.marko b/test/migrate/fixtures/widget-in-attrs/template.marko index baf6c4c3f..459b8a5bf 100644 --- a/test/migrate/fixtures/widget-in-attrs/template.marko +++ b/test/migrate/fixtures/widget-in-attrs/template.marko @@ -2,4 +2,6 @@
- \ No newline at end of file + + + \ No newline at end of file