@rambler-tech/dom
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -6,2 +6,6 @@ # Change Log | ||
## [0.2.1](https://github.com/rambler-digital-solutions/rambler-common/compare/@rambler-tech/dom@0.2.0...@rambler-tech/dom@0.2.1) (2024-09-27) | ||
**Note:** Version bump only for package @rambler-tech/dom | ||
# [0.2.0](https://github.com/rambler-digital-solutions/rambler-common/compare/@rambler-tech/dom@0.1.0...@rambler-tech/dom@0.2.0) (2024-09-06) | ||
@@ -8,0 +12,0 @@ |
@@ -1,7 +0,4 @@ | ||
"use strict"; | ||
/* eslint-disable import/no-unused-modules */ | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.loadScript = exports.loadStyleSheet = exports.injectStyleSheet = void 0; | ||
/** Inject style sheet to DOM */ | ||
function injectStyleSheet(cssText, attributes = {}) { | ||
export function injectStyleSheet(cssText, attributes = {}) { | ||
const style = document.createElement('style'); | ||
@@ -16,10 +13,8 @@ style.textContent = cssText; | ||
} | ||
exports.injectStyleSheet = injectStyleSheet; | ||
const REGISTRY = '__ASSETS_REGISTRY__'; | ||
globalThis[REGISTRY] = {}; | ||
/** Load style sheet */ | ||
function loadStyleSheet(source) { | ||
export function loadStyleSheet(source) { | ||
var _a; | ||
var _b; | ||
(_a = (_b = globalThis[REGISTRY])[source]) !== null && _a !== void 0 ? _a : (_b[source] = new Promise((resolve, reject) => { | ||
(_a = globalThis[REGISTRY])[source] ?? (_a[source] = new Promise((resolve, reject) => { | ||
const link = document.createElement('link'); | ||
@@ -38,8 +33,6 @@ link.rel = 'stylesheet'; | ||
} | ||
exports.loadStyleSheet = loadStyleSheet; | ||
/** Load script */ | ||
function loadScript(source, attributes = {}) { | ||
export function loadScript(source, attributes = {}) { | ||
var _a; | ||
var _b; | ||
(_a = (_b = globalThis[REGISTRY])[source]) !== null && _a !== void 0 ? _a : (_b[source] = new Promise((resolve, reject) => { | ||
(_a = globalThis[REGISTRY])[source] ?? (_a[source] = new Promise((resolve, reject) => { | ||
const script = document.createElement('script'); | ||
@@ -64,2 +57,1 @@ script.src = source; | ||
} | ||
exports.loadScript = loadScript; |
@@ -1,4 +0,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const _1 = require("."); | ||
import { injectStyleSheet } from '.'; | ||
test('inject style', () => { | ||
@@ -9,3 +7,3 @@ const button = document.createElement('button'); | ||
expect(window.getComputedStyle(button).display).toBe('inline-block'); | ||
(0, _1.injectStyleSheet)('.test-button {display: flex;}'); | ||
injectStyleSheet('.test-button {display: flex;}'); | ||
expect(window.getComputedStyle(button).display).toBe('flex'); | ||
@@ -18,3 +16,3 @@ }); | ||
expect(window.getComputedStyle(button).display).toBe('inline-block'); | ||
const style = (0, _1.injectStyleSheet)('.test-button-2 {display: flex;}', { | ||
const style = injectStyleSheet('.test-button-2 {display: flex;}', { | ||
'data-scope': 'button' | ||
@@ -21,0 +19,0 @@ }); |
{ | ||
"name": "@rambler-tech/dom", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"main": "dist", | ||
@@ -12,3 +12,3 @@ "module": "dist", | ||
}, | ||
"gitHead": "1fc7adc5c9141ed10da6c7e3f74d9f6ff3a41457" | ||
"gitHead": "c051bf08ebfeb3f2541548469c3280dcb9fa4a2e" | ||
} |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
8174
164
1