UNPKG

eslint-plugin-vue-scoped-css

Version:
51 lines (50 loc) 1.63 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getAttributeValueNodes = getAttributeValueNodes; const templates_1 = require("../../../utils/templates"); const reference_expression_1 = require("./reference-expression"); function getAttributeValueNodes(element, name, context) { const results = []; const { startTag } = element; for (const attr of startTag.attributes) { if (!(0, templates_1.isVDirective)(attr)) { const { key, value } = attr; if (value == null) { continue; } if (key.name === name) { results.push(value); } } else { const { key, value } = attr; if (value == null) { continue; } if (!(0, templates_1.isVBind)(key)) { continue; } const bindArg = (0, templates_1.getArgument)(key); if (bindArg == null) { return null; } if (bindArg !== name) { continue; } const { expression } = value; if (expression == null) { continue; } if (expression.type === "VGenericExpression") continue; const expressions = (0, reference_expression_1.getReferenceExpressions)(expression, context); if (!expressions) { return null; } for (const e of expressions) { results.push(e); } } } return results; }