pax_global_header00006660000000000000000000000064140332611230014505gustar00rootroot0000000000000052 comment=e24778654416e14cfcf259253b916e32e53aaa75 is-potential-custom-element-name-1.0.1/000077500000000000000000000000001403326112300177715ustar00rootroot00000000000000is-potential-custom-element-name-1.0.1/.editorconfig000066400000000000000000000003161403326112300224460ustar00rootroot00000000000000root = true [*] charset = utf-8 indent_style = tab end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true [{README.md,package.json,.travis.yml}] indent_style = space indent_size = 2 is-potential-custom-element-name-1.0.1/.gitattributes000066400000000000000000000000141403326112300226570ustar00rootroot00000000000000* text=auto is-potential-custom-element-name-1.0.1/.gitignore000066400000000000000000000003131403326112300217560ustar00rootroot00000000000000# Installed npm modules node_modules # Folder view configuration files .DS_Store Desktop.ini # Thumbnail cache files ._* Thumbs.db # Files that might appear on external disks .Spotlight-V100 .Trashes is-potential-custom-element-name-1.0.1/.travis.yml000066400000000000000000000000641403326112300221020ustar00rootroot00000000000000language: node_js node_js: - "14" git: depth: 1 is-potential-custom-element-name-1.0.1/LICENSE-MIT.txt000066400000000000000000000020651403326112300222460ustar00rootroot00000000000000Copyright Mathias Bynens Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. is-potential-custom-element-name-1.0.1/README.md000066400000000000000000000024611403326112300212530ustar00rootroot00000000000000# is-potential-custom-element-name [![Build status](https://travis-ci.org/mathiasbynens/is-potential-custom-element-name.svg?branch=master)](https://travis-ci.org/mathiasbynens/is-potential-custom-element-name) _is-potential-custom-element-name_ checks whether a given string matches [the `PotentialCustomElementName` production](https://html.spec.whatwg.org/multipage/scripting.html#prod-potentialcustomelementname) as defined in the HTML Standard. ## Installation To use _is-potential-custom-element-name_ programmatically, install it as a dependency via [npm](https://www.npmjs.com/): ```bash $ npm install is-potential-custom-element-name ``` Then, `require` it: ```js const isPotentialCustomElementName = require('is-potential-custom-element-name'); ``` ## Usage ```js isPotentialCustomElementName('foo-bar'); // → true isPotentialCustomElementName('Foo-bar'); // → false isPotentialCustomElementName('baz-©'); // → false isPotentialCustomElementName('annotation-xml'); // → true ``` ## Author | [![twitter/mathias](https://gravatar.com/avatar/24e08a9ea84deb17ae121074d0f17125?s=70)](https://twitter.com/mathias "Follow @mathias on Twitter") | |---| | [Mathias Bynens](https://mathiasbynens.be/) | ## License _is-potential-custom-element-name_ is available under the [MIT](https://mths.be/mit) license. is-potential-custom-element-name-1.0.1/build.js000066400000000000000000000027121403326112300214300ustar00rootroot00000000000000'use strict'; const fs = require('fs'); const regenerate = require('regenerate'); // https://html.spec.whatwg.org/multipage/scripting.html#valid-custom-element-name // PCENChar ::= // "-" | "." | [0-9] | "_" | [a-z] | #xB7 | [#xC0-#xD6] | [#xD8-#xF6] | [#xF8-#x37D] | [#x37F-#x1FFF] | [#x200C-#x200D] | [#x203F-#x2040] | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | [#xF900-#xFDCF] | [#xFDF0-#xFFFD] | [#x10000-#xEFFFF] const set = regenerate('-', '.', '_', 0x00B7) .addRange('0', '9') .addRange('a', 'z') .addRange(0x00C0, 0x00D6) .addRange(0x00D8, 0x00F6) .addRange(0x00F8, 0x037D) .addRange(0x037F, 0x1FFF) .addRange(0x200C, 0x200D) .addRange(0x203F, 0x2040) .addRange(0x2070, 0x218F) .addRange(0x2C00, 0x2FEF) .addRange(0x3001, 0xD7FF) .addRange(0xF900, 0xFDCF) .addRange(0xFDF0, 0xFFFD) .addRange(0x010000, 0x0EFFFF); const PCENChar = set.toString(); const PCENCharNoHyphen = set.clone().remove('-').toString(); // PotentialCustomElementName ::= // [a-z] (PCENChar)* '-' (PCENChar)* // Note: The hyphen is omitted from the first group to avoid excess backtracking. const PotentialCustomElementName = `[a-z](?:${ PCENCharNoHyphen })*-(?:${ PCENChar })*`; const source = `// Generated using \`npm run build\`. Do not edit. var regex = /^${ PotentialCustomElementName }$/; var isPotentialCustomElementName = function(string) { return regex.test(string); }; module.exports = isPotentialCustomElementName; `; fs.writeFileSync('index.js', source); is-potential-custom-element-name-1.0.1/index.js000077500000000000000000000011001403326112300214310ustar00rootroot00000000000000// Generated using `npm run build`. Do not edit. 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 isPotentialCustomElementName = function(string) { return regex.test(string); }; module.exports = isPotentialCustomElementName; is-potential-custom-element-name-1.0.1/package.json000066400000000000000000000016501403326112300222610ustar00rootroot00000000000000{ "name": "is-potential-custom-element-name", "version": "1.0.1", "description": "Check whether a given string matches the `PotentialCustomElementName` production as defined in the HTML Standard.", "homepage": "https://github.com/mathiasbynens/is-potential-custom-element-name", "main": "index.js", "files": [ "LICENSE-MIT.txt", "index.js" ], "keywords": [ "html", "custom element", "custom element name", "web components" ], "license": "MIT", "author": { "name": "Mathias Bynens", "url": "https://mathiasbynens.be/" }, "repository": { "type": "git", "url": "https://github.com/mathiasbynens/is-potential-custom-element-name.git" }, "bugs": "https://github.com/mathiasbynens/is-potential-custom-element-name/issues", "devDependencies": { "mocha": "^2.2.1", "regenerate": "^1.4.2" }, "scripts": { "build": "node build.js", "test": "mocha" } } is-potential-custom-element-name-1.0.1/test.js000066400000000000000000000012671403326112300213140ustar00rootroot00000000000000var assert = require('assert'); var isPotentialCustomElementName = require('./index.js'); describe('is-potential-custom-element-name', function() { it('returns a boolean indicating whether the given string is a potential custom element name', function() { assert.equal(isPotentialCustomElementName('foo-bar'), true); assert.equal(isPotentialCustomElementName('Foo-bar'), false); assert.equal(isPotentialCustomElementName('baz-©'), false); assert.equal(isPotentialCustomElementName('annotation-xml'), true); }); it('avoids excess backtracking', function() { const longA = 'a'.repeat(20000000); assert.strictEqual(isPotentialCustomElementName('a-'.concat(longA)), true); }) });