UNPKG

eslint-plugin-vue-scoped-css

Version:
54 lines (53 loc) 1.92 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isRootElement = isRootElement; exports.isSkipElement = isSkipElement; exports.isSlotElement = isSlotElement; exports.getWrapperTransition = getWrapperTransition; exports.isElementWrappedInTransition = isElementWrappedInTransition; exports.getParentElement = getParentElement; const templates_1 = require("../../../utils/templates"); function isRootElement(element) { return element.type === "VElement" && isRootTemplate(element.parent); } function isRootTemplate(element) { return (element.type === "VElement" && element.name === "template" && element.parent.type === "VDocumentFragment"); } function isSkipElement(element) { return (element.type === "VElement" && (element.name === "template" || (0, templates_1.isTransitionElement)(element))); } function isSlotElement(element) { return element.type === "VElement" && element.name === "slot"; } function getWrapperTransition(element) { let parent = element.parent; while (parent.type === "VElement") { if ((0, templates_1.isTransitionElement)(parent) || (0, templates_1.isTransitionGroupElement)(parent)) { return parent; } if (!isSlotElement(parent) && !isSkipElement(parent)) { return null; } parent = parent.parent; } return null; } function isElementWrappedInTransition(element) { return Boolean(getWrapperTransition(element)); } function getParentElement(element) { if (isRootElement(element)) { return null; } let parent = element.parent; while (parent && (isSkipElement(parent) || isSlotElement(parent))) { if (isRootElement(parent)) { return null; } parent = parent.parent; } return (parent === null || parent === void 0 ? void 0 : parent.type) === "VElement" ? parent : null; }