UNPKG

marko-widgets

Version:

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

60 lines (59 loc) 2.6 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 widget_reference_exports = {}; __export(widget_reference_exports, { default: () => widget_reference_default }); module.exports = __toCommonJS(widget_reference_exports); var import_compiler = require("@marko/compiler"); var import_babel_utils = require("@marko/babel-utils"); var import_compat_utils = require("@marko/compat-utils"); var widget_reference_default = { Identifier(id) { if (id.node.name === "widget" && !id.scope.hasBinding("widget", true) && id.isReferencedIdentifier()) { if (id.parentPath.isMemberExpression() && (0, import_compat_utils.isMemberProperty)(id.parentPath.node, "elId") && id.parentPath.parentPath.isCallExpression() && id.parentPath.parentPath.node.arguments.length <= 1 && id.parentPath.parentPath.parentPath.isMarkoAttribute()) { (0, import_babel_utils.diagnosticDeprecate)(id, { label: "The widget.elId() method is deprecated. In this case it can be refactored to used the :scoped modifier.", fix() { const call = id.parentPath.parentPath; const attr = call.parentPath; attr.replaceWith( import_compiler.types.markoAttribute( attr.node.name, call.node.arguments[0] || import_compiler.types.booleanLiteral(true), "scoped" ) ); } }); } else { (0, import_babel_utils.diagnosticDeprecate)(id, { label: `The "widget" variable is deprecated. Please use "component" instead.`, fix() { const newId = import_compiler.types.identifier("component"); newId.start = id.node.start; newId.end = id.node.end; newId.loc = id.node.loc; id.replaceWith(newId); } }); } } } };