Skip to content

Commit

Permalink
fix: issue mixing scoped and no-update directives
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Dec 29, 2024
1 parent 6ef629b commit cb3b4b5
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/wet-lizards-repair.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"marko": patch
---

Fix issue where scoped directive was being applied twice when tag had no-update directive.
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,27 @@ import { types as t } from "@marko/compiler";

import withPreviousLocation from "../../../util/with-previous-location";

const seen = new WeakSet();

export default {
exit(tag, _, value) {
const {
hub: { file },
} = tag;
value.replaceWith(
withPreviousLocation(
t.callExpression(
t.memberExpression(
file._componentDefIdentifier,
t.identifier("elId"),
),
[value.node],
),
value.node,

if (seen.has(value.node)) {
return;
}

const replacement = withPreviousLocation(
t.callExpression(
t.memberExpression(file._componentDefIdentifier, t.identifier("elId")),
[value.node],
),
value.node,
);

seen.add(replacement);
value.replaceWith(replacement);
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"use strict";

exports.__esModule = true;
exports.default = void 0;
var _index = require("marko/src/runtime/html/index.js");
var _dataMarko = _interopRequireDefault(require("marko/src/runtime/html/helpers/data-marko.js"));
var _attr = _interopRequireDefault(require("marko/src/runtime/html/helpers/attr.js"));
var _preserveTag = _interopRequireDefault(require("marko/src/core-tags/components/preserve-tag.js"));
var _renderTag = _interopRequireDefault(require("marko/src/runtime/helpers/render-tag.js"));
var _renderer = _interopRequireDefault(require("marko/src/runtime/components/renderer.js"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const _marko_componentType = "__tests__/template.marko",
_marko_template = (0, _index.t)(_marko_componentType);
var _default = exports.default = _marko_template;
const _marko_component = {};
_marko_template._ = (0, _renderer.default)(function (input, out, _componentDef, _component, state, $global) {
(0, _renderTag.default)(_preserveTag.default, {
"n": true,
"renderBody": out => {
out.w(`<input${(0, _dataMarko.default)(out, _componentDef, 0, "0")}${(0, _attr.default)("id", _componentDef.elId("input1"))}>`);
}
}, out, _componentDef, "0");
}, {
t: _marko_componentType,
i: true,
d: true
}, _marko_component);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<input id:scoped="input1" no-update>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { t as _t } from "marko/src/runtime/html/index.js";
const _marko_componentType = "__tests__/template.marko",
_marko_template = _t(_marko_componentType);
export default _marko_template;
import _marko_props from "marko/src/runtime/html/helpers/data-marko.js";
import _marko_attr from "marko/src/runtime/html/helpers/attr.js";
import _preserve from "marko/src/core-tags/components/preserve-tag.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(_preserve, {
"n": true,
"renderBody": out => {
out.w(`<input${_marko_props(out, _componentDef, 0, "0")}${_marko_attr("id", _componentDef.elId("input1"))}>`);
}
}, out, _componentDef, "0");
}, {
t: _marko_componentType,
i: true,
d: true
}, _marko_component);
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { t as _t } from "marko/dist/runtime/html/index.js";
const _marko_componentType = "FiW8Sbt",
_marko_template = _t(_marko_componentType);
export default _marko_template;
import _marko_props from "marko/dist/runtime/html/helpers/data-marko.js";
import _marko_attr from "marko/dist/runtime/html/helpers/attr.js";
import _preserve from "marko/dist/core-tags/components/preserve-tag.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(_preserve, {
"n": true,
"renderBody": out => {
out.w(`<input${_marko_props(out, _componentDef, 0, "0")}${_marko_attr("id", _componentDef.elId("input1"))}>`);
}
}, out, _componentDef, "0");
}, {
t: _marko_componentType,
i: true
}, _marko_component);
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { t as _t } from "marko/src/runtime/vdom/index.js";
const _marko_componentType = "__tests__/template.marko",
_marko_template = _t(_marko_componentType);
export default _marko_template;
import _preserve from "marko/src/core-tags/components/preserve-tag.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(_preserve, {
"n": true,
"renderBody": out => {
out.e("input", {
"id": _componentDef.elId("input1")
}, "0", _component, 0, 1);
}
}, out, _componentDef, "0");
}, {
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._);
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { t as _t } from "marko/dist/runtime/vdom/index.js";
const _marko_componentType = "FiW8Sbt",
_marko_template = _t(_marko_componentType);
export default _marko_template;
import _preserve from "marko/dist/core-tags/components/preserve-tag.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(_preserve, {
"n": true,
"renderBody": out => {
out.e("input", {
"id": _componentDef.elId("input1")
}, "0", _component, 0, 1);
}
}, out, _componentDef, "0");
}, {
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._);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<input id:scoped="input1" no-update>

0 comments on commit cb3b4b5

Please sign in to comment.