UNPKG

marko-widgets

Version:

<h1 align="center"> <!-- Logo --> <br/> marko-widgets@8 <br/>

49 lines (48 loc) 2.13 kB
"use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var w_id_directive_exports = {}; __export(w_id_directive_exports, { default: () => w_id_directive_default }); module.exports = __toCommonJS(w_id_directive_exports); var import_compiler = require("@marko/compiler"); var import_babel_utils = require("@marko/babel-utils"); var import_compat_utils = require("@marko/compat-utils"); var w_id_directive_default = { MarkoAttribute(attr) { var _a; const { node } = attr; if (node.name !== "w-id") return; (_a = attr.hub.file.metadata.marko).widgetBind || (_a.widgetBind = true); (0, import_babel_utils.diagnosticDeprecate)(attr, { label: `The "w-id" attribute is deprecated. Please use "key" attribute instead. See: https://github.com/marko-js/marko/wiki/Deprecation:-w\u2010*-Attributes`, fix() { const tag = attr.parentPath; const value = attr.node.value; if (!(0, import_compat_utils.hasAttribute)(tag, "id") && !(value.type === "StringLiteral" && value.value.endsWith("[]")) && ((0, import_babel_utils.isNativeTag)(tag) || (0, import_babel_utils.isDynamicTag)(tag))) { tag.unshiftContainer( "attributes", import_compiler.types.markoAttribute("id", value, "scoped") ); } attr.replaceWith(import_compiler.types.markoAttribute("key", value)); } }); } };