@spectrum-web-components/shared
Advanced tools
Comparing version 0.12.2 to 0.12.3
@@ -6,2 +6,9 @@ # Change Log | ||
## [0.12.3](https://github.com/adobe/spectrum-web-components/compare/@spectrum-web-components/shared@0.12.2...@spectrum-web-components/shared@0.12.3) (2021-05-12) | ||
### Bug Fixes | ||
- allow rendered anchors to be aria-hidden ([2e9aa23](https://github.com/adobe/spectrum-web-components/commit/2e9aa2324013e1d2311a8d4307dafe17912328ee)) | ||
- update "reparentChildren" types for flexibility ([2d358be](https://github.com/adobe/spectrum-web-components/commit/2d358be094cf73785d0858545ccd0f9ca2aa8db0)) | ||
## [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) | ||
@@ -8,0 +15,0 @@ |
{ | ||
"name": "@spectrum-web-components/shared", | ||
"version": "0.12.2", | ||
"version": "0.12.3", | ||
"publishConfig": { | ||
@@ -50,3 +50,3 @@ "access": "public" | ||
"sideEffects": false, | ||
"gitHead": "1bd2f11dc1f2485a583e02fb5163ec5f5804df66" | ||
"gitHead": "50e608e54fbf56132aeed4433299fbcf7f6893ac" | ||
} |
@@ -6,2 +6,8 @@ import { UpdatingElement, TemplateResult } from '@spectrum-web-components/base'; | ||
}; | ||
declare type RenderAnchorOptions = { | ||
id: string; | ||
className?: string; | ||
ariaHidden?: boolean; | ||
anchorContent?: TemplateResult | TemplateResult[]; | ||
}; | ||
export interface LikeAnchorInterface { | ||
@@ -13,9 +19,5 @@ download?: string; | ||
target?: '_blank' | '_parent' | '_self' | '_top'; | ||
renderAnchor(options: { | ||
id: string; | ||
className?: string; | ||
anchorContent?: TemplateResult | TemplateResult[]; | ||
}): TemplateResult; | ||
renderAnchor(options: RenderAnchorOptions): TemplateResult; | ||
} | ||
export declare function LikeAnchor<T extends Constructor<UpdatingElement>>(constructor: T): T & Constructor<LikeAnchorInterface>; | ||
export {}; |
@@ -16,5 +16,5 @@ import { __decorate } from "tslib"; | ||
class LikeAnchorElement extends constructor { | ||
renderAnchor({ id, className, | ||
renderAnchor({ id, className, ariaHidden, | ||
// prettier-ignore | ||
anchorContent = html `<slot></slot>` }) { | ||
anchorContent = html `<slot></slot>`, }) { | ||
// prettier-ignore | ||
@@ -28,2 +28,3 @@ return html `<a | ||
aria-label=${ifDefined(this.label)} | ||
aria-hidden=${ifDefined(ariaHidden ? 'true' : undefined)} | ||
rel=${ifDefined(this.rel)} | ||
@@ -30,0 +31,0 @@ >${anchorContent}</a>`; |
@@ -26,2 +26,9 @@ /* | ||
type RenderAnchorOptions = { | ||
id: string; | ||
className?: string; | ||
ariaHidden?: boolean; | ||
anchorContent?: TemplateResult | TemplateResult[]; | ||
}; | ||
export interface LikeAnchorInterface { | ||
@@ -33,7 +40,3 @@ download?: string; | ||
target?: '_blank' | '_parent' | '_self' | '_top'; | ||
renderAnchor(options: { | ||
id: string; | ||
className?: string; | ||
anchorContent?: TemplateResult | TemplateResult[]; | ||
}): TemplateResult; | ||
renderAnchor(options: RenderAnchorOptions): TemplateResult; | ||
} | ||
@@ -63,9 +66,6 @@ | ||
className, | ||
ariaHidden, | ||
// prettier-ignore | ||
anchorContent = html`<slot></slot>` | ||
}: { | ||
id: string; | ||
className?: string; | ||
anchorContent: TemplateResult | TemplateResult[]; | ||
}): TemplateResult { | ||
anchorContent = html`<slot></slot>`, | ||
}: RenderAnchorOptions): TemplateResult { | ||
// prettier-ignore | ||
@@ -80,2 +80,3 @@ return html | ||
aria-label=${ifDefined(this.label)} | ||
aria-hidden=${ifDefined(ariaHidden ? 'true' : undefined)} | ||
rel=${ifDefined(this.rel)} | ||
@@ -82,0 +83,0 @@ >${anchorContent}</a>`; |
@@ -1,1 +0,1 @@ | ||
export declare const reparentChildren: (srcElements: Element[], newParent: Element, prepareCallback?: ((el: Element) => void | ((el: Element) => void)) | undefined) => (() => Element[]); | ||
export declare const reparentChildren: <T extends Element>(srcElements: T[], newParent: Element, prepareCallback?: ((el: T) => void | ((el: T) => void)) | undefined) => (() => Element[]); |
@@ -0,1 +1,12 @@ | ||
/* | ||
Copyright 2020 Adobe. All rights reserved. | ||
This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. You may obtain a copy | ||
of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software distributed under | ||
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
OF ANY KIND, either express or implied. See the License for the specific language | ||
governing permissions and limitations under the License. | ||
*/ | ||
function restoreChildren(placeholderItems, srcElements, cleanupCallbacks = []) { | ||
@@ -15,4 +26,4 @@ for (let index = 0; index < srcElements.length; ++index) { | ||
export const reparentChildren = (srcElements, newParent, prepareCallback) => { | ||
let placeholderItems = []; | ||
let cleanupCallbacks = []; | ||
const placeholderItems = []; | ||
const cleanupCallbacks = []; | ||
for (let index = 0; index < srcElements.length; ++index) { | ||
@@ -23,3 +34,6 @@ const placeholderItem = document.createComment('placeholder for reparented element'); | ||
if (prepareCallback) { | ||
cleanupCallbacks.push(prepareCallback(srcElement) || ((_el) => { })); | ||
cleanupCallbacks.push(prepareCallback(srcElement) || | ||
(() => { | ||
return; | ||
})); | ||
} | ||
@@ -26,0 +40,0 @@ const parentElement = srcElement.parentElement || srcElement.getRootNode(); |
@@ -1,6 +0,17 @@ | ||
function restoreChildren( | ||
/* | ||
Copyright 2020 Adobe. All rights reserved. | ||
This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. You may obtain a copy | ||
of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software distributed under | ||
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
OF ANY KIND, either express or implied. See the License for the specific language | ||
governing permissions and limitations under the License. | ||
*/ | ||
function restoreChildren<T extends Element>( | ||
placeholderItems: Comment[], | ||
srcElements: Element[], | ||
cleanupCallbacks: ((el: Element) => void)[] = [] | ||
): Element[] { | ||
srcElements: T[], | ||
cleanupCallbacks: ((el: T) => void)[] = [] | ||
): T[] { | ||
for (let index = 0; index < srcElements.length; ++index) { | ||
@@ -20,9 +31,9 @@ const srcElement = srcElements[index]; | ||
export const reparentChildren = ( | ||
srcElements: Element[], | ||
export const reparentChildren = <T extends Element>( | ||
srcElements: T[], | ||
newParent: Element, | ||
prepareCallback?: (el: Element) => ((el: Element) => void) | void | ||
prepareCallback?: (el: T) => ((el: T) => void) | void | ||
): (() => Element[]) => { | ||
let placeholderItems: Comment[] = []; | ||
let cleanupCallbacks: ((el: Element) => void)[] = []; | ||
const placeholderItems: Comment[] = []; | ||
const cleanupCallbacks: ((el: T) => void)[] = []; | ||
@@ -38,3 +49,6 @@ for (let index = 0; index < srcElements.length; ++index) { | ||
cleanupCallbacks.push( | ||
prepareCallback(srcElement) || ((_el: Element) => {}) | ||
prepareCallback(srcElement) || | ||
(() => { | ||
return; | ||
}) | ||
); | ||
@@ -49,4 +63,8 @@ } | ||
return function (): Element[] { | ||
return restoreChildren(placeholderItems, srcElements, cleanupCallbacks); | ||
return restoreChildren<T>( | ||
placeholderItems, | ||
srcElements, | ||
cleanupCallbacks | ||
); | ||
}; | ||
}; |
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
131113
1411