@spectrum-web-components/shared
Advanced tools
Comparing version 0.12.2-beta.17 to 0.12.2
@@ -6,2 +6,6 @@ # Change Log | ||
## [0.12.2](https://github.com/adobe/spectrum-web-components/compare/@spectrum-web-components/shared@0.12.1...@spectrum-web-components/shared@0.12.2) (2021-04-09) | ||
**Note:** Version bump only for package @spectrum-web-components/shared | ||
## [0.12.1](https://github.com/adobe/spectrum-web-components/compare/@spectrum-web-components/shared@0.12.0...@spectrum-web-components/shared@0.12.1) (2021-03-29) | ||
@@ -8,0 +12,0 @@ |
{ | ||
"name": "@spectrum-web-components/shared", | ||
"version": "0.12.2", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"description": "", | ||
"license": "Apache-2.0", | ||
"repository": { | ||
@@ -11,17 +14,9 @@ "type": "git", | ||
}, | ||
"author": "", | ||
"homepage": "https://adobe.github.io/spectrum-web-components/components/shared", | ||
"bugs": { | ||
"url": "https://github.com/adobe/spectrum-web-components/issues" | ||
}, | ||
"homepage": "https://adobe.github.io/spectrum-web-components/components/shared", | ||
"keywords": [ | ||
"spectrum css", | ||
"web components", | ||
"lit-element", | ||
"lit-html" | ||
], | ||
"version": "0.12.2-beta.17+324d05fa", | ||
"description": "", | ||
"main": "./src/index.js", | ||
"module": "./src/index.js", | ||
"types": "./src/index.d.ts", | ||
"type": "module", | ||
@@ -33,21 +28,26 @@ "exports": { | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: run tests from mono-repo root.\" && exit 1" | ||
}, | ||
"files": [ | ||
"custom-elements.json", | ||
"*.d.ts", | ||
"*.js", | ||
"*.js.map", | ||
"/src/" | ||
"/src/", | ||
"custom-elements.json" | ||
], | ||
"sideEffects": false, | ||
"scripts": { | ||
"test": "echo \"Error: run tests from mono-repo root.\" && exit 1" | ||
}, | ||
"author": "", | ||
"license": "Apache-2.0", | ||
"keywords": [ | ||
"spectrum css", | ||
"web components", | ||
"lit-element", | ||
"lit-html" | ||
], | ||
"dependencies": { | ||
"@spectrum-web-components/base": "^0.4.3-beta.43+324d05fa", | ||
"@spectrum-web-components/base": "^0.4.3", | ||
"focus-visible": "^5.1.0", | ||
"tslib": "^2.0.0" | ||
}, | ||
"gitHead": "324d05fa305732201905cd628d702e47f086cbff" | ||
"types": "./src/index.d.ts", | ||
"sideEffects": false, | ||
"gitHead": "1bd2f11dc1f2485a583e02fb5163ec5f5804df66" | ||
} |
@@ -1,1 +0,1 @@ | ||
export declare const reparentChildren: (srcElements: Element[], newParent: Element) => (() => Element[]); | ||
export declare const reparentChildren: (srcElements: Element[], newParent: Element, prepareCallback?: ((el: Element) => void | ((el: Element) => void)) | undefined) => (() => Element[]); |
@@ -1,2 +0,2 @@ | ||
function restoreChildren(placeholderItems, srcElements, slotNames) { | ||
function restoreChildren(placeholderItems, srcElements, cleanupCallbacks = []) { | ||
for (let index = 0; index < srcElements.length; ++index) { | ||
@@ -6,4 +6,4 @@ const srcElement = srcElements[index]; | ||
const parentElement = placeholderItem.parentElement || placeholderItem.getRootNode(); | ||
if (slotNames[index]) { | ||
srcElement.slot = slotNames[index]; | ||
if (cleanupCallbacks[index]) { | ||
cleanupCallbacks[index](srcElement); | ||
} | ||
@@ -15,5 +15,5 @@ parentElement.replaceChild(srcElement, placeholderItem); | ||
} | ||
export const reparentChildren = (srcElements, newParent) => { | ||
export const reparentChildren = (srcElements, newParent, prepareCallback) => { | ||
let placeholderItems = []; | ||
let slotNames = []; | ||
let cleanupCallbacks = []; | ||
for (let index = 0; index < srcElements.length; ++index) { | ||
@@ -23,4 +23,5 @@ const placeholderItem = document.createComment('placeholder for reparented element'); | ||
const srcElement = srcElements[index]; | ||
slotNames.push(srcElement.slot); | ||
srcElement.removeAttribute('slot'); | ||
if (prepareCallback) { | ||
cleanupCallbacks.push(prepareCallback(srcElement) || ((_el) => { })); | ||
} | ||
const parentElement = srcElement.parentElement || srcElement.getRootNode(); | ||
@@ -31,5 +32,5 @@ parentElement.replaceChild(placeholderItem, srcElement); | ||
return function () { | ||
return restoreChildren(placeholderItems, srcElements, slotNames); | ||
return restoreChildren(placeholderItems, srcElements, cleanupCallbacks); | ||
}; | ||
}; | ||
//# sourceMappingURL=reparent-children.js.map |
function restoreChildren( | ||
placeholderItems: Comment[], | ||
srcElements: Element[], | ||
slotNames: string[] | ||
cleanupCallbacks: ((el: Element) => void)[] = [] | ||
): Element[] { | ||
@@ -11,4 +11,4 @@ for (let index = 0; index < srcElements.length; ++index) { | ||
placeholderItem.parentElement || placeholderItem.getRootNode(); | ||
if (slotNames[index]) { | ||
srcElement.slot = slotNames[index]; | ||
if (cleanupCallbacks[index]) { | ||
cleanupCallbacks[index](srcElement); | ||
} | ||
@@ -23,6 +23,7 @@ parentElement.replaceChild(srcElement, placeholderItem); | ||
srcElements: Element[], | ||
newParent: Element | ||
newParent: Element, | ||
prepareCallback?: (el: Element) => ((el: Element) => void) | void | ||
): (() => Element[]) => { | ||
let placeholderItems: Comment[] = []; | ||
let slotNames: string[] = []; | ||
let cleanupCallbacks: ((el: Element) => void)[] = []; | ||
@@ -36,4 +37,7 @@ for (let index = 0; index < srcElements.length; ++index) { | ||
const srcElement = srcElements[index]; | ||
slotNames.push(srcElement.slot); | ||
srcElement.removeAttribute('slot'); | ||
if (prepareCallback) { | ||
cleanupCallbacks.push( | ||
prepareCallback(srcElement) || ((_el: Element) => {}) | ||
); | ||
} | ||
const parentElement = | ||
@@ -46,4 +50,4 @@ srcElement.parentElement || srcElement.getRootNode(); | ||
return function (): Element[] { | ||
return restoreChildren(placeholderItems, srcElements, slotNames); | ||
return restoreChildren(placeholderItems, srcElements, cleanupCallbacks); | ||
}; | ||
}; |
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
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
128169
1378
0