@webext-core/isolated-element
Advanced tools
Comparing version 1.1.1 to 1.1.2
@@ -6,3 +6,6 @@ /** | ||
/** | ||
* A unique tag name used when defining the web component used internally. Don't use the same name twice for different UIs. | ||
* A unique HTML tag name (two words, kebab case - [see spec](https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name)) used when defining the web component used internally. Don't use the same name twice for different UIs. | ||
* @example "sticky-note" | ||
* @example "anime-skip-player" | ||
* @example "github-better-line-count-diff" | ||
*/ | ||
@@ -9,0 +12,0 @@ name: string; |
"use strict"; | ||
var webExtCoreIsolatedElement = (() => { | ||
var __create = Object.create; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __getProtoOf = Object.getPrototypeOf; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __commonJS = (cb, mod) => function __require() { | ||
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; | ||
}; | ||
var __export = (target, all) => { | ||
@@ -19,2 +24,6 @@ for (var name in all) | ||
}; | ||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( | ||
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, | ||
mod | ||
)); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
@@ -42,2 +51,13 @@ var __async = (__this, __arguments, generator) => { | ||
// ../../node_modules/.pnpm/is-potential-custom-element-name@1.0.1/node_modules/is-potential-custom-element-name/index.js | ||
var require_is_potential_custom_element_name = __commonJS({ | ||
"../../node_modules/.pnpm/is-potential-custom-element-name@1.0.1/node_modules/is-potential-custom-element-name/index.js"(exports, module) { | ||
var regex = /^[a-z](?:[\.0-9_a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*-(?:[\x2D\.0-9_a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*$/; | ||
var isPotentialCustomElementName2 = function(string) { | ||
return regex.test(string); | ||
}; | ||
module.exports = isPotentialCustomElementName2; | ||
} | ||
}); | ||
// src/index.ts | ||
@@ -48,5 +68,11 @@ var src_exports = {}; | ||
}); | ||
var import_is_potential_custom_element_name = __toESM(require_is_potential_custom_element_name(), 1); | ||
function createIsolatedElement(options) { | ||
return __async(this, null, function* () { | ||
const { name, mode = "closed", css, isolateEvents = false } = options; | ||
if (!(0, import_is_potential_custom_element_name.default)(name)) { | ||
throw Error( | ||
`"${name}" is not a valid custom element name. It must be two words and kebab-case, with a few exceptions. See spec for more details: https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name` | ||
); | ||
} | ||
const parentElement = document.createElement(name); | ||
@@ -53,0 +79,0 @@ const shadow = parentElement.attachShadow({ mode }); |
@@ -23,5 +23,11 @@ var __async = (__this, __arguments, generator) => { | ||
// src/index.ts | ||
import isPotentialCustomElementName from "is-potential-custom-element-name"; | ||
function createIsolatedElement(options) { | ||
return __async(this, null, function* () { | ||
const { name, mode = "closed", css, isolateEvents = false } = options; | ||
if (!isPotentialCustomElementName(name)) { | ||
throw Error( | ||
`"${name}" is not a valid custom element name. It must be two words and kebab-case, with a few exceptions. See spec for more details: https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name` | ||
); | ||
} | ||
const parentElement = document.createElement(name); | ||
@@ -28,0 +34,0 @@ const shadow = parentElement.attachShadow({ mode }); |
{ | ||
"name": "@webext-core/isolated-element", | ||
"version": "1.1.1", | ||
"version": "1.1.2", | ||
"description": "Isolate content script UI's styles from the parent page. Supports all browsers (Chrome, Firefox, Safari)", | ||
@@ -45,2 +45,3 @@ "license": "MIT", | ||
"devDependencies": { | ||
"@types/is-potential-custom-element-name": "^1.0.0", | ||
"@vitest/coverage-c8": "^0.24.5", | ||
@@ -53,2 +54,5 @@ "jsdom": "^20.0.3", | ||
}, | ||
"dependencies": { | ||
"is-potential-custom-element-name": "^1.0.1" | ||
}, | ||
"scripts": { | ||
@@ -55,0 +59,0 @@ "build": "tsup src/index.ts --clean --out-dir lib --dts --format esm,cjs,iife --global-name webExtCoreIsolatedElement", |
Sorry, the diff of this file is not supported yet
16403
323
1
7
+ Addedis-potential-custom-element-name@1.0.1(transitive)