123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 |
-
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- Object.defineProperty(exports, "movePseudos", {
- enumerable: true,
- get: function() {
- return movePseudos;
- }
- });
- let elementProperties = {
-
- "::after": [
- "terminal",
- "jumpable"
- ],
- "::backdrop": [
- "terminal",
- "jumpable"
- ],
- "::before": [
- "terminal",
- "jumpable"
- ],
- "::cue": [
- "terminal"
- ],
- "::cue-region": [
- "terminal"
- ],
- "::first-letter": [
- "terminal",
- "jumpable"
- ],
- "::first-line": [
- "terminal",
- "jumpable"
- ],
- "::grammar-error": [
- "terminal"
- ],
- "::marker": [
- "terminal",
- "jumpable"
- ],
- "::part": [
- "terminal",
- "actionable"
- ],
- "::placeholder": [
- "terminal",
- "jumpable"
- ],
- "::selection": [
- "terminal",
- "jumpable"
- ],
- "::slotted": [
- "terminal"
- ],
- "::spelling-error": [
- "terminal"
- ],
- "::target-text": [
- "terminal"
- ],
-
- "::file-selector-button": [
- "terminal",
- "actionable"
- ],
-
-
- "::deep": [
- "actionable"
- ],
- "::v-deep": [
- "actionable"
- ],
- "::ng-deep": [
- "actionable"
- ],
-
-
-
-
- ":after": [
- "terminal",
- "jumpable"
- ],
- ":before": [
- "terminal",
- "jumpable"
- ],
- ":first-letter": [
- "terminal",
- "jumpable"
- ],
- ":first-line": [
- "terminal",
- "jumpable"
- ],
- ":where": [],
- ":is": [],
- ":has": [],
-
-
-
- __default__: [
- "terminal",
- "actionable"
- ]
- };
- function movePseudos(sel) {
- let [pseudos] = movablePseudos(sel);
-
- pseudos.forEach(([sel, pseudo])=>sel.removeChild(pseudo));
-
-
-
-
-
-
-
-
-
-
- sel.nodes.push(...pseudos.map(([, pseudo])=>pseudo));
- return sel;
- }
-
- function movablePseudos(sel) {
- let buffer = [];
- let lastSeenElement = null;
- for (let node of sel.nodes){
- if (node.type === "combinator") {
- buffer = buffer.filter(([, node])=>propertiesForPseudo(node).includes("jumpable"));
- lastSeenElement = null;
- } else if (node.type === "pseudo") {
- if (isMovablePseudoElement(node)) {
- lastSeenElement = node;
- buffer.push([
- sel,
- node,
- null
- ]);
- } else if (lastSeenElement && isAttachablePseudoClass(node, lastSeenElement)) {
- buffer.push([
- sel,
- node,
- lastSeenElement
- ]);
- } else {
- lastSeenElement = null;
- }
- var _node_nodes;
- for (let sub of (_node_nodes = node.nodes) !== null && _node_nodes !== void 0 ? _node_nodes : []){
- let [movable, lastSeenElementInSub] = movablePseudos(sub);
- lastSeenElement = lastSeenElementInSub || lastSeenElement;
- buffer.push(...movable);
- }
- }
- }
- return [
- buffer,
- lastSeenElement
- ];
- }
- function isPseudoElement(node) {
- return node.value.startsWith("::") || elementProperties[node.value] !== undefined;
- }
- function isMovablePseudoElement(node) {
- return isPseudoElement(node) && propertiesForPseudo(node).includes("terminal");
- }
- function isAttachablePseudoClass(node, pseudo) {
- if (node.type !== "pseudo") return false;
- if (isPseudoElement(node)) return false;
- return propertiesForPseudo(pseudo).includes("actionable");
- }
- function propertiesForPseudo(pseudo) {
- var _elementProperties_pseudo_value;
- return (_elementProperties_pseudo_value = elementProperties[pseudo.value]) !== null && _elementProperties_pseudo_value !== void 0 ? _elementProperties_pseudo_value : elementProperties.__default__;
- }
|