Comparing version 0.2.6 to 0.2.7
@@ -1,1 +0,1 @@ | ||
{"processes":{"598731f2-a3ad-4949-9223-0a6f2fd43780":{"parent":null,"children":[]}},"files":{"/home/dmonad/ylabs/lib0/dist/test.cjs":["598731f2-a3ad-4949-9223-0a6f2fd43780"]},"externalIds":{}} | ||
{"processes":{"167bd912-1145-4e23-b01a-4a50e13b22f2":{"parent":null,"children":[]}},"files":{"/home/dmonad/ylabs/lib0/dist/test.cjs":["167bd912-1145-4e23-b01a-4a50e13b22f2"]},"externalIds":{}} |
@@ -8,2 +8,3 @@ /* eslint-env browser */ | ||
import * as string from './string.js' | ||
import * as array from './array.js' | ||
@@ -233,7 +234,10 @@ export const registry = customElements | ||
for (const key in slotElems) { | ||
const currentSlot = dom.querySelector(this, `[slot="${key}"]`) | ||
const nextSlot = dom.parseElement(slotElems[key]) | ||
nextSlot.setAttribute('slot', key) | ||
if (currentSlot) { | ||
dom.replaceWith(currentSlot, nextSlot) | ||
const currentSlots = /** @type {Array<any>} */ (key !== 'default' ? array.from(dom.querySelectorAll(this, `[slot="${key}"]`)) : array.from(this.childNodes).filter(/** @param {any} child */ child => !dom.checkNodeType(child, dom.ELEMENT_NODE) || !child.hasAttribute('slot'))) | ||
currentSlots.slice(1).map(dom.remove) | ||
const nextSlot = dom.parseFragment(slotElems[key]) | ||
if (key !== 'default') { | ||
array.from(nextSlot.children).forEach(c => c.setAttribute('slot', key)) | ||
} | ||
if (currentSlots.length > 0) { | ||
dom.replaceWith(currentSlots[0], nextSlot) | ||
} else { | ||
@@ -240,0 +244,0 @@ dom.appendChild(this, nextSlot) |
28
dom.js
@@ -95,2 +95,8 @@ /* eslint-env browser */ | ||
/** | ||
* @param {HTMLElement} el | ||
*/ | ||
/* istanbul ignore next */ | ||
export const remove = el => el.remove() | ||
/** | ||
* @param {EventTarget} el | ||
@@ -219,3 +225,3 @@ * @param {string} name | ||
/* istanbul ignore next */ | ||
export const parseFragment = html => fragment(_parse(html).children) | ||
export const parseFragment = html => fragment(/** @type {any} */ (_parse(html).childNodes)) | ||
@@ -231,3 +237,3 @@ /** | ||
* @param {HTMLElement} oldEl | ||
* @param {HTMLElement} newEl | ||
* @param {HTMLElement|DocumentFragment} newEl | ||
*/ | ||
@@ -248,6 +254,20 @@ /* istanbul ignore next */ | ||
* @param {HTMLElement} parent | ||
* @param {HTMLElement} child | ||
* @return {HTMLElement} | ||
* @param {HTMLElement|DocumentFragment} child | ||
* @return {HTMLElement|DocumentFragment} | ||
*/ | ||
/* istanbul ignore next */ | ||
export const appendChild = (parent, child) => parent.appendChild(child) | ||
export const ELEMENT_NODE = document.ELEMENT_NODE | ||
export const TEXT_NODE = document.TEXT_NODE | ||
export const CDATA_SECTION_NODE = document.CDATA_SECTION_NODE | ||
export const COMMENT_NODE = document.COMMENT_NODE | ||
export const DOCUMENT_NODE = document.DOCUMENT_NODE | ||
export const DOCUMENT_TYPE_NODE = document.DOCUMENT_TYPE_NODE | ||
export const DOCUMENT_FRAGMENT_NODE = document.DOCUMENT_FRAGMENT_NODE | ||
/** | ||
* @param {any} node | ||
* @param {number} type | ||
*/ | ||
export const checkNodeType = (node, type) => node.nodeType === type |
{ | ||
"name": "lib0", | ||
"version": "0.2.6", | ||
"version": "0.2.7", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1985549
19719