From da01103a43c41e6ee37979b9d963b6bb0ade418c Mon Sep 17 00:00:00 2001 From: LuLaValva Date: Tue, 9 Jul 2024 09:13:38 -0700 Subject: [PATCH] test(translator): check for shadowing `data` with a tag destructure --- .../snapshots/cjs-expected.js | 35 +++++++++++++++++++ .../generated-expected.diagnostics.txt | 1 + .../snapshots/generated-expected.marko | 10 ++++++ .../snapshots/html-expected.js | 30 ++++++++++++++++ .../snapshots/htmlProduction-expected.js | 29 +++++++++++++++ .../snapshots/hydrate-expected.js | 0 .../snapshots/vdom-expected.js | 34 ++++++++++++++++++ .../snapshots/vdomProduction-expected.js | 33 +++++++++++++++++ .../fixtures/data-destructure/template.marko | 7 ++++ 9 files changed, 179 insertions(+) create mode 100644 packages/translator-default/test/fixtures/data-destructure/snapshots/cjs-expected.js create mode 100644 packages/translator-default/test/fixtures/data-destructure/snapshots/generated-expected.diagnostics.txt create mode 100644 packages/translator-default/test/fixtures/data-destructure/snapshots/generated-expected.marko create mode 100644 packages/translator-default/test/fixtures/data-destructure/snapshots/html-expected.js create mode 100644 packages/translator-default/test/fixtures/data-destructure/snapshots/htmlProduction-expected.js create mode 100644 packages/translator-default/test/fixtures/data-destructure/snapshots/hydrate-expected.js create mode 100644 packages/translator-default/test/fixtures/data-destructure/snapshots/vdom-expected.js create mode 100644 packages/translator-default/test/fixtures/data-destructure/snapshots/vdomProduction-expected.js create mode 100644 packages/translator-default/test/fixtures/data-destructure/template.marko diff --git a/packages/translator-default/test/fixtures/data-destructure/snapshots/cjs-expected.js b/packages/translator-default/test/fixtures/data-destructure/snapshots/cjs-expected.js new file mode 100644 index 0000000000..b93004433e --- /dev/null +++ b/packages/translator-default/test/fixtures/data-destructure/snapshots/cjs-expected.js @@ -0,0 +1,35 @@ +"use strict"; + +exports.__esModule = true; +exports.default = void 0; +var _index = require("marko/src/runtime/html/index.js"); +var _attrTag = require("marko/src/runtime/helpers/attr-tag.js"); +var _renderer = _interopRequireDefault(require("marko/src/core-tags/core/await/renderer.js")); +var _renderTag = _interopRequireDefault(require("marko/src/runtime/helpers/render-tag.js")); +var _renderer2 = _interopRequireDefault(require("marko/src/runtime/components/renderer.js")); +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } +const _marko_componentType = "packages/translator-default/test/fixtures/data-destructure/template.marko", + _marko_template = (0, _index.t)(_marko_componentType); +var _default = exports.default = _marko_template; +const _marko_component = {}; +_marko_template._ = (0, _renderer2.default)(function (input, out, _componentDef, _component, state, $global) { + (0, _renderTag.default)(_renderer.default, (0, _attrTag.i)(() => { + (0, _attrTag.a)("then", { + "renderBody": (out, { + data + }) => { + console.log(data); + } + }); + }, { + "_provider": Promise.resolve({ + data: true + }), + "_name": "Promise.resolve({\n data: true\n})" + }), out, _componentDef, "0"); + console.log(input); +}, { + t: _marko_componentType, + i: true, + d: true +}, _marko_component); \ No newline at end of file diff --git a/packages/translator-default/test/fixtures/data-destructure/snapshots/generated-expected.diagnostics.txt b/packages/translator-default/test/fixtures/data-destructure/snapshots/generated-expected.diagnostics.txt new file mode 100644 index 0000000000..2ed59dcb13 --- /dev/null +++ b/packages/translator-default/test/fixtures/data-destructure/snapshots/generated-expected.diagnostics.txt @@ -0,0 +1 @@ +deprecation[fixable](7:15-7:19): The 'data' variable is deprecated. Use 'input' instead. diff --git a/packages/translator-default/test/fixtures/data-destructure/snapshots/generated-expected.marko b/packages/translator-default/test/fixtures/data-destructure/snapshots/generated-expected.marko new file mode 100644 index 0000000000..1cf4bdfd23 --- /dev/null +++ b/packages/translator-default/test/fixtures/data-destructure/snapshots/generated-expected.marko @@ -0,0 +1,10 @@ + + <@then|{ + data + }|> + $ console.log(data); + + +$ console.log(input); \ No newline at end of file diff --git a/packages/translator-default/test/fixtures/data-destructure/snapshots/html-expected.js b/packages/translator-default/test/fixtures/data-destructure/snapshots/html-expected.js new file mode 100644 index 0000000000..d360aab151 --- /dev/null +++ b/packages/translator-default/test/fixtures/data-destructure/snapshots/html-expected.js @@ -0,0 +1,30 @@ +import { t as _t } from "marko/src/runtime/html/index.js"; +const _marko_componentType = "packages/translator-default/test/fixtures/data-destructure/template.marko", + _marko_template = _t(_marko_componentType); +export default _marko_template; +import { a as _marko_repeatable_attr_tag, i as _marko_render_input } from "marko/src/runtime/helpers/attr-tag.js"; +import _await from "marko/src/core-tags/core/await/renderer.js"; +import _marko_tag from "marko/src/runtime/helpers/render-tag.js"; +import _marko_renderer from "marko/src/runtime/components/renderer.js"; +const _marko_component = {}; +_marko_template._ = _marko_renderer(function (input, out, _componentDef, _component, state, $global) { + _marko_tag(_await, _marko_render_input(() => { + _marko_repeatable_attr_tag("then", { + "renderBody": (out, { + data + }) => { + console.log(data); + } + }); + }, { + "_provider": Promise.resolve({ + data: true + }), + "_name": "Promise.resolve({\n data: true\n})" + }), out, _componentDef, "0"); + console.log(input); +}, { + t: _marko_componentType, + i: true, + d: true +}, _marko_component); \ No newline at end of file diff --git a/packages/translator-default/test/fixtures/data-destructure/snapshots/htmlProduction-expected.js b/packages/translator-default/test/fixtures/data-destructure/snapshots/htmlProduction-expected.js new file mode 100644 index 0000000000..be82b21bba --- /dev/null +++ b/packages/translator-default/test/fixtures/data-destructure/snapshots/htmlProduction-expected.js @@ -0,0 +1,29 @@ +import { t as _t } from "marko/dist/runtime/html/index.js"; +const _marko_componentType = "yrkdiQvb", + _marko_template = _t(_marko_componentType); +export default _marko_template; +import { a as _marko_repeatable_attr_tag, i as _marko_render_input } from "marko/dist/runtime/helpers/attr-tag.js"; +import _await from "marko/dist/core-tags/core/await/renderer.js"; +import _marko_tag from "marko/dist/runtime/helpers/render-tag.js"; +import _marko_renderer from "marko/dist/runtime/components/renderer.js"; +const _marko_component = {}; +_marko_template._ = _marko_renderer(function (input, out, _componentDef, _component, state, $global) { + _marko_tag(_await, _marko_render_input(() => { + _marko_repeatable_attr_tag("then", { + "renderBody": (out, { + data + }) => { + console.log(data); + } + }); + }, { + "_provider": Promise.resolve({ + data: true + }), + "_name": "Promise.resolve({\n data: true\n})" + }), out, _componentDef, "0"); + console.log(input); +}, { + t: _marko_componentType, + i: true +}, _marko_component); \ No newline at end of file diff --git a/packages/translator-default/test/fixtures/data-destructure/snapshots/hydrate-expected.js b/packages/translator-default/test/fixtures/data-destructure/snapshots/hydrate-expected.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/translator-default/test/fixtures/data-destructure/snapshots/vdom-expected.js b/packages/translator-default/test/fixtures/data-destructure/snapshots/vdom-expected.js new file mode 100644 index 0000000000..2c2de0dfca --- /dev/null +++ b/packages/translator-default/test/fixtures/data-destructure/snapshots/vdom-expected.js @@ -0,0 +1,34 @@ +import { t as _t } from "marko/src/runtime/vdom/index.js"; +const _marko_componentType = "packages/translator-default/test/fixtures/data-destructure/template.marko", + _marko_template = _t(_marko_componentType); +export default _marko_template; +import { a as _marko_repeatable_attr_tag, i as _marko_render_input } from "marko/src/runtime/helpers/attr-tag.js"; +import _await from "marko/src/core-tags/core/await/renderer.js"; +import _marko_tag from "marko/src/runtime/helpers/render-tag.js"; +import _marko_renderer from "marko/src/runtime/components/renderer.js"; +import { r as _marko_registerComponent } from "marko/src/runtime/components/registry.js"; +_marko_registerComponent(_marko_componentType, () => _marko_template); +const _marko_component = {}; +_marko_template._ = _marko_renderer(function (input, out, _componentDef, _component, state, $global) { + _marko_tag(_await, _marko_render_input(() => { + _marko_repeatable_attr_tag("then", { + "renderBody": (out, { + data + }) => { + console.log(data); + } + }); + }, { + "_provider": Promise.resolve({ + data: true + }), + "_name": "Promise.resolve({\n data: true\n})" + }), out, _componentDef, "0"); + console.log(input); +}, { + t: _marko_componentType, + i: true, + d: true +}, _marko_component); +import _marko_defineComponent from "marko/src/runtime/components/defineComponent.js"; +_marko_template.Component = _marko_defineComponent(_marko_component, _marko_template._); \ No newline at end of file diff --git a/packages/translator-default/test/fixtures/data-destructure/snapshots/vdomProduction-expected.js b/packages/translator-default/test/fixtures/data-destructure/snapshots/vdomProduction-expected.js new file mode 100644 index 0000000000..bf8e13a15d --- /dev/null +++ b/packages/translator-default/test/fixtures/data-destructure/snapshots/vdomProduction-expected.js @@ -0,0 +1,33 @@ +import { t as _t } from "marko/dist/runtime/vdom/index.js"; +const _marko_componentType = "yrkdiQvb", + _marko_template = _t(_marko_componentType); +export default _marko_template; +import { a as _marko_repeatable_attr_tag, i as _marko_render_input } from "marko/dist/runtime/helpers/attr-tag.js"; +import _await from "marko/dist/core-tags/core/await/renderer.js"; +import _marko_tag from "marko/dist/runtime/helpers/render-tag.js"; +import _marko_renderer from "marko/dist/runtime/components/renderer.js"; +import { r as _marko_registerComponent } from "marko/dist/runtime/components/registry.js"; +_marko_registerComponent(_marko_componentType, () => _marko_template); +const _marko_component = {}; +_marko_template._ = _marko_renderer(function (input, out, _componentDef, _component, state, $global) { + _marko_tag(_await, _marko_render_input(() => { + _marko_repeatable_attr_tag("then", { + "renderBody": (out, { + data + }) => { + console.log(data); + } + }); + }, { + "_provider": Promise.resolve({ + data: true + }), + "_name": "Promise.resolve({\n data: true\n})" + }), out, _componentDef, "0"); + console.log(input); +}, { + t: _marko_componentType, + i: true +}, _marko_component); +import _marko_defineComponent from "marko/dist/runtime/components/defineComponent.js"; +_marko_template.Component = _marko_defineComponent(_marko_component, _marko_template._); \ No newline at end of file diff --git a/packages/translator-default/test/fixtures/data-destructure/template.marko b/packages/translator-default/test/fixtures/data-destructure/template.marko new file mode 100644 index 0000000000..3629d49199 --- /dev/null +++ b/packages/translator-default/test/fixtures/data-destructure/template.marko @@ -0,0 +1,7 @@ + + <@then|{data}|> + $ console.log(data) + + + +$ console.log(data); \ No newline at end of file