From a5dfa884ee44f683b64c61bbb7fb17fd178b2d1d Mon Sep 17 00:00:00 2001 From: Michael Rawlings Date: Wed, 20 Mar 2019 15:10:22 -0700 Subject: [PATCH] fix widget.elId as / attribute (#1298) --- src/taglibs/migrate/all-tags/widget-in-attrs.js | 6 +++++- .../fixtures/widget-in-attrs/snapshot-expected.marko | 2 ++ test/migrate/fixtures/widget-in-attrs/template.marko | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) 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