@awsui/theming-runtime
Advanced tools
Comparing version 1.0.56 to 1.0.57
/** | ||
* Creates a style elemenet from CSS String and an optional nonce value and returns it. The node | ||
* Creates a style element from CSS String and an optional nonce value and returns it. The node | ||
* will have an extra attribute for identification. | ||
@@ -9,7 +9,8 @@ * @param content CSS string | ||
export declare function createStyleNode(content: string, nonce?: string): HTMLStyleElement; | ||
export declare function appendStyleNode(node: HTMLStyleElement): void; | ||
export declare function appendStyleNode(node: HTMLStyleElement, targetDocument?: Document): void; | ||
/** | ||
* Parses meta tags to find name="nonce" and returns the value | ||
* @param targetDocument optional target HTML document to parse meta tags from. By default current document is used. | ||
* @returns nonce from meta tag | ||
*/ | ||
export declare function getNonce(): string | undefined; | ||
export declare function getNonce(targetDocument?: Document): string | undefined; |
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
/** | ||
* Creates a style elemenet from CSS String and an optional nonce value and returns it. The node | ||
* Creates a style element from CSS String and an optional nonce value and returns it. The node | ||
* will have an extra attribute for identification. | ||
@@ -18,13 +18,16 @@ * @param content CSS string | ||
} | ||
export function appendStyleNode(node) { | ||
document.head.appendChild(node); | ||
export function appendStyleNode(node, targetDocument) { | ||
if (targetDocument === void 0) { targetDocument = document; } | ||
targetDocument.head.appendChild(node); | ||
} | ||
/** | ||
* Parses meta tags to find name="nonce" and returns the value | ||
* @param targetDocument optional target HTML document to parse meta tags from. By default current document is used. | ||
* @returns nonce from meta tag | ||
*/ | ||
export function getNonce() { | ||
export function getNonce(targetDocument) { | ||
var _a; | ||
var metaTag = document.querySelector('meta[name="nonce"]'); | ||
if (targetDocument === void 0) { targetDocument = document; } | ||
var metaTag = targetDocument.querySelector('meta[name="nonce"]'); | ||
return (_a = metaTag === null || metaTag === void 0 ? void 0 : metaTag.content) !== null && _a !== void 0 ? _a : undefined; | ||
} |
@@ -6,2 +6,3 @@ import { ThemePreset, Override } from '../shared/theme'; | ||
baseThemeId?: string; | ||
targetDocument?: Document; | ||
} | ||
@@ -8,0 +9,0 @@ export interface ApplyThemeResult { |
@@ -9,3 +9,3 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
export function applyTheme(params) { | ||
var override = params.override, preset = params.preset, baseThemeId = params.baseThemeId; | ||
var override = params.override, preset = params.preset, baseThemeId = params.baseThemeId, targetDocument = params.targetDocument; | ||
var availableContexts = getContexts(preset); | ||
@@ -15,5 +15,5 @@ var validated = validateOverride(override, preset.themeable, availableContexts); | ||
var content = createOverrideDeclarations(theme, validated, preset.propertiesMap, createMultiThemeCustomizer(preset.theme.selector)); | ||
var nonce = getNonce(); | ||
var nonce = getNonce(targetDocument); | ||
var styleNode = createStyleNode(content, nonce); | ||
appendStyleNode(styleNode); | ||
appendStyleNode(styleNode, targetDocument); | ||
return { | ||
@@ -20,0 +20,0 @@ reset: function () { |
{ | ||
"commit": "2a31329f7bb6b37173726f05c9838827daf9f15e" | ||
"commit": "5379a7892f458481add9ce05158b92f1c66b18ab" | ||
} |
{ | ||
"version": "1.0.56", | ||
"version": "1.0.57", | ||
"name": "@awsui/theming-runtime", | ||
@@ -4,0 +4,0 @@ "main": "./browser/index.js", |
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
70419
1349