Last change
on this file since bdd6491 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
715 bytes
|
Line | |
---|
1 | "use strict";
|
---|
2 |
|
---|
3 | Object.defineProperty(exports, "__esModule", {
|
---|
4 | value: true
|
---|
5 | });
|
---|
6 | exports.default = canUnquote;
|
---|
7 |
|
---|
8 | /**
|
---|
9 | * Can unquote attribute detection from mothereff.in
|
---|
10 | * Copyright Mathias Bynens <https://mathiasbynens.be/>
|
---|
11 | * https://github.com/mathiasbynens/mothereff.in
|
---|
12 | */
|
---|
13 | const escapes = /\\([0-9A-Fa-f]{1,6})[ \t\n\f\r]?/g; // eslint-disable-next-line no-control-regex
|
---|
14 |
|
---|
15 | const range = /[\u0000-\u002c\u002e\u002f\u003A-\u0040\u005B-\u005E\u0060\u007B-\u009f]/;
|
---|
16 |
|
---|
17 | function canUnquote(value) {
|
---|
18 | if (value === '-' || value === '') {
|
---|
19 | return false;
|
---|
20 | }
|
---|
21 |
|
---|
22 | value = value.replace(escapes, 'a').replace(/\\./g, 'a');
|
---|
23 | return !(range.test(value) || /^(?:-?\d|--)/.test(value));
|
---|
24 | }
|
---|
25 |
|
---|
26 | module.exports = exports.default; |
---|
Note:
See
TracBrowser
for help on using the repository browser.