marko-widgets
Version:
<h1 align="center"> <!-- Logo --> <br/> marko-widgets@8 <br/>
37 lines (35 loc) • 1.04 kB
JavaScript
// packages/marko-widgets/src/migrate/w-for.ts
import { types as t } from "@marko/compiler";
import { diagnosticDeprecate } from "@marko/babel-utils";
import { getAttribute } from "@marko/compat-utils";
var w_for_default = {
MarkoAttribute(attr) {
const { node } = attr;
switch (node.name) {
case "w-for":
case "for-key":
case "for-ref":
break;
default:
return;
}
const tag = attr.parentPath;
const forAttr = getAttribute(tag, "for");
if (forAttr) {
diagnosticDeprecate(attr, {
label: `The "${node.name}" attribute cannot be used in conjunction with the "for" attribute.`
});
attr.remove();
return;
}
diagnosticDeprecate(attr, {
label: `The "${node.name}" attribute is deprecated. Please use "for:scoped" instead. See: https://github.com/marko-js/marko/wiki/Deprecation:-w\u2010*-Attributes`,
fix() {
attr.replaceWith(t.markoAttribute("for", node.value, "scoped"));
}
});
}
};
export {
w_for_default
};