| 11043 | document.head.appendChild(styleEl); |
| 11044 | } |
| 11045 | function substituteSlots(templateSource, slotContent, scopeSel) { |
| 11046 | if (!slotContent) return templateSource; |
| 11047 | var tmp = document.createElement("div"); |
| 11048 | tmp.innerHTML = slotContent; |
| 11049 | var named = {}; |
| 11050 | var defaultParts = []; |
| 11051 | for (var child of Array.from(tmp.childNodes)) { |
| 11052 | if (child.nodeType === 1 && scopeSel && !child.hasAttribute("dom-scope")) { |
| 11053 | child.setAttribute("dom-scope", "parent of " + scopeSel); |
| 11054 | } |
| 11055 | var slotName = child.nodeType === 1 && child.getAttribute("slot"); |
| 11056 | if (slotName) { |
| 11057 | child.removeAttribute("slot"); |
| 11058 | if (!named[slotName]) named[slotName] = ""; |
| 11059 | named[slotName] += child.outerHTML; |
| 11060 | } else { |
| 11061 | defaultParts.push(child.nodeType === 1 ? child.outerHTML : child.nodeType === 3 ? child.textContent : ""); |
| 11062 | } |
| 11063 | } |
| 11064 | var defaultContent = defaultParts.join(""); |
| 11065 | var source = templateSource.replace( |
| 11066 | /<slot\s+name\s*=\s*["']([^"']+)["']\s*\/?\s*>(\s*<\/slot>)?/g, |
| 11067 | function(_, name) { |
| 11068 | return named[name] || ""; |
| 11069 | } |
| 11070 | ); |
| 11071 | source = source.replace(/<slot\s*\/?\s*>(\s*<\/slot>)?/g, defaultContent); |
| 11072 | return source; |
| 11073 | } |
| 11074 | function parseArg(componentEl, prop) { |
| 11075 | if (typeof prop !== "string") return null; |
| 11076 | var cache = componentEl._attrsCache || (componentEl._attrsCache = {}); |