Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
{
"version": 3,
"sources": ["../../../src/util/SlotsHelper.ts"],
"sourcesContent": ["/**\n * Determines the slot to which a node should be assigned\n * @param node Text node or HTML element\n * @returns {string}\n */\nconst getSlotName = (node: Node) => {\n\t// Text nodes can only go to the default slot\n\tif (!(node instanceof HTMLElement)) {\n\t\treturn \"default\";\n\t}\n\n\t// Discover the slot based on the real slot name (f.e. footer => footer, or content-32 => content)\n\tconst slot = node.getAttribute(\"slot\");\n\tif (slot) {\n\t\tconst match = slot.match(/^(.+?)-\\d+$/);\n\t\treturn match ? match[1] : slot;\n\t}\n\n\t// Use default slot as a fallback\n\treturn \"default\";\n};\n\nconst getSlottedNodes = (node: Node) => {\n\tif (node instanceof HTMLSlotElement) {\n\t\treturn node.assignedNodes({ flatten: true }).filter(item => item instanceof HTMLElement);\n\t}\n\n\treturn [node];\n};\n\nconst getSlottedNodesList = (nodeList: Array) => {\n\treturn nodeList.reduce((acc, curr) => acc.concat(getSlottedNodes(curr)), [] as Array);\n};\n\nexport {\n\tgetSlotName,\n\tgetSlottedNodes,\n\tgetSlottedNodesList,\n};\n"],
"mappings": "aAKA,MAAMA,EAAeC,GAAe,CAEnC,GAAI,EAAEA,aAAgB,aACrB,MAAO,UAIR,MAAMC,EAAOD,EAAK,aAAa,MAAM,EACrC,GAAIC,EAAM,CACT,MAAMC,EAAQD,EAAK,MAAM,aAAa,EACtC,OAAOC,EAAQA,EAAM,CAAC,EAAID,CAC3B,CAGA,MAAO,SACR,EAEME,EAAmBH,GACpBA,aAAgB,gBACZA,EAAK,cAAc,CAAE,QAAS,EAAK,CAAC,EAAE,OAAOI,GAAQA,aAAgB,WAAW,EAGjF,CAACJ,CAAI,EAGPK,EAAuBC,GACrBA,EAAS,OAAO,CAACC,EAAKC,IAASD,EAAI,OAAOJ,EAAgBK,CAAI,CAAC,EAAG,CAAC,CAAgB,EAG3F,OACCT,KAAA,YACAI,KAAA,gBACAE,KAAA",
"names": ["getSlotName", "node", "slot", "match", "getSlottedNodes", "item", "getSlottedNodesList", "nodeList", "acc", "curr"]
}