| [9af201e] | 1 | var functionNoVendorRegexStr = '[A-Z]+(\\-|[A-Z]|[0-9])+\\(.*?\\)';
|
|---|
| 2 | var functionVendorRegexStr = '\\-(\\-|[A-Z]|[0-9])+\\(.*?\\)';
|
|---|
| 3 | var variableRegexStr = 'var\\(\\-\\-[^\\)]+\\)';
|
|---|
| 4 | var functionAnyRegexStr = '(' + variableRegexStr + '|' + functionNoVendorRegexStr + '|' + functionVendorRegexStr + ')';
|
|---|
| 5 |
|
|---|
| 6 | var calcRegex = new RegExp('^(\\-moz\\-|\\-webkit\\-)?calc\\([^\\)]+\\)$', 'i');
|
|---|
| 7 | var decimalRegex = /[0-9]/;
|
|---|
| 8 | var functionAnyRegex = new RegExp('^' + functionAnyRegexStr + '$', 'i');
|
|---|
| 9 | var hexAlphaColorRegex = /^#(?:[0-9a-f]{4}|[0-9a-f]{8})$/i;
|
|---|
| 10 | // eslint-disable-next-line max-len
|
|---|
| 11 | var hslColorRegex = /^hsl\(\s{0,31}[-.]?\d+\s{0,31},\s{0,31}\d*\.?\d+%\s{0,31},\s{0,31}\d*\.?\d+%\s{0,31}\)|hsla\(\s{0,31}[-.]?\d+\s{0,31},\s{0,31}\d*\.?\d+%\s{0,31},\s{0,31}\d*\.?\d+%\s{0,31},\s{0,31}\.?\d+\s{0,31}\)$/;
|
|---|
| 12 | // eslint-disable-next-line max-len
|
|---|
| 13 | var hslColorWithSpacesRegex = /^hsl\(\s{0,31}[-.]?\d+(deg)?\s{1,31}\d*\.?\d+%\s{1,31}\d*\.?\d+%\s{0,31}\)|hsla\(\s{0,31}[-.]?\d+(deg)?\s{1,31}\d*\.?\d+%\s{1,31}\d*\.?\d+%\s{1,31}\/\s{1,31}\d*\.?\d+%?\s{0,31}\)$/;
|
|---|
| 14 | var identifierRegex = /^(-[a-z0-9_][a-z0-9\-_]*|[a-z_][a-z0-9\-_]*)$/i;
|
|---|
| 15 | var namedEntityRegex = /^[a-z]+$/i;
|
|---|
| 16 | var prefixRegex = /^-([a-z0-9]|-)*$/i;
|
|---|
| 17 | var quotedTextRegex = /^("[^"]*"|'[^']*')$/i;
|
|---|
| 18 | // eslint-disable-next-line max-len
|
|---|
| 19 | var rgbColorRegex = /^rgb\(\s{0,31}[\d]{1,3}\s{0,31},\s{0,31}[\d]{1,3}\s{0,31},\s{0,31}[\d]{1,3}\s{0,31}\)|rgba\(\s{0,31}[\d]{1,3}\s{0,31},\s{0,31}[\d]{1,3}\s{0,31},\s{0,31}[\d]{1,3}\s{0,31},\s{0,31}[.\d]+\s{0,31}\)$/i;
|
|---|
| 20 | // eslint-disable-next-line max-len
|
|---|
| 21 | var rgbColorWithSpacesRegex = /^rgb\(\s{0,31}[\d]{1,3}\s{1,31}[\d]{1,3}\s{1,31}[\d]{1,3}\s{0,31}\)|rgba\(\s{0,31}[\d]{1,3}\s{1,31}[\d]{1,3}\s{1,31}[\d]{1,3}\s{1,31}\/\s{1,31}[\d]*\.?[.\d]+%?\s{0,31}\)$/i;
|
|---|
| 22 | var timeUnitPattern = /\d+(s|ms)/;
|
|---|
| 23 | var timingFunctionRegex = /^(cubic-bezier|steps)\([^)]+\)$/;
|
|---|
| 24 | var validTimeUnits = ['ms', 's'];
|
|---|
| 25 | var urlRegex = /^url\([\s\S]+\)$/i;
|
|---|
| 26 | var variableRegex = new RegExp('^' + variableRegexStr + '$', 'i');
|
|---|
| 27 |
|
|---|
| 28 | var eightValueColorRegex = /^#[0-9a-f]{8}$/i;
|
|---|
| 29 | var fourValueColorRegex = /^#[0-9a-f]{4}$/i;
|
|---|
| 30 | var sixValueColorRegex = /^#[0-9a-f]{6}$/i;
|
|---|
| 31 | var threeValueColorRegex = /^#[0-9a-f]{3}$/i;
|
|---|
| 32 |
|
|---|
| 33 | var DECIMAL_DOT = '.';
|
|---|
| 34 | var MINUS_SIGN = '-';
|
|---|
| 35 | var PLUS_SIGN = '+';
|
|---|
| 36 |
|
|---|
| 37 | var Keywords = {
|
|---|
| 38 | '^': [
|
|---|
| 39 | 'inherit',
|
|---|
| 40 | 'initial',
|
|---|
| 41 | 'unset'
|
|---|
| 42 | ],
|
|---|
| 43 | '*-style': [
|
|---|
| 44 | 'auto',
|
|---|
| 45 | 'dashed',
|
|---|
| 46 | 'dotted',
|
|---|
| 47 | 'double',
|
|---|
| 48 | 'groove',
|
|---|
| 49 | 'hidden',
|
|---|
| 50 | 'inset',
|
|---|
| 51 | 'none',
|
|---|
| 52 | 'outset',
|
|---|
| 53 | 'ridge',
|
|---|
| 54 | 'solid'
|
|---|
| 55 | ],
|
|---|
| 56 | '*-timing-function': [
|
|---|
| 57 | 'ease',
|
|---|
| 58 | 'ease-in',
|
|---|
| 59 | 'ease-in-out',
|
|---|
| 60 | 'ease-out',
|
|---|
| 61 | 'linear',
|
|---|
| 62 | 'step-end',
|
|---|
| 63 | 'step-start'
|
|---|
| 64 | ],
|
|---|
| 65 | 'animation-direction': [
|
|---|
| 66 | 'alternate',
|
|---|
| 67 | 'alternate-reverse',
|
|---|
| 68 | 'normal',
|
|---|
| 69 | 'reverse'
|
|---|
| 70 | ],
|
|---|
| 71 | 'animation-fill-mode': [
|
|---|
| 72 | 'backwards',
|
|---|
| 73 | 'both',
|
|---|
| 74 | 'forwards',
|
|---|
| 75 | 'none'
|
|---|
| 76 | ],
|
|---|
| 77 | 'animation-iteration-count': [
|
|---|
| 78 | 'infinite'
|
|---|
| 79 | ],
|
|---|
| 80 | 'animation-name': [
|
|---|
| 81 | 'none'
|
|---|
| 82 | ],
|
|---|
| 83 | 'animation-play-state': [
|
|---|
| 84 | 'paused',
|
|---|
| 85 | 'running'
|
|---|
| 86 | ],
|
|---|
| 87 | 'background-attachment': [
|
|---|
| 88 | 'fixed',
|
|---|
| 89 | 'inherit',
|
|---|
| 90 | 'local',
|
|---|
| 91 | 'scroll'
|
|---|
| 92 | ],
|
|---|
| 93 | 'background-clip': [
|
|---|
| 94 | 'border-box',
|
|---|
| 95 | 'content-box',
|
|---|
| 96 | 'inherit',
|
|---|
| 97 | 'padding-box',
|
|---|
| 98 | 'text'
|
|---|
| 99 | ],
|
|---|
| 100 | 'background-origin': [
|
|---|
| 101 | 'border-box',
|
|---|
| 102 | 'content-box',
|
|---|
| 103 | 'inherit',
|
|---|
| 104 | 'padding-box'
|
|---|
| 105 | ],
|
|---|
| 106 | 'background-position': [
|
|---|
| 107 | 'bottom',
|
|---|
| 108 | 'center',
|
|---|
| 109 | 'left',
|
|---|
| 110 | 'right',
|
|---|
| 111 | 'top'
|
|---|
| 112 | ],
|
|---|
| 113 | 'background-repeat': [
|
|---|
| 114 | 'no-repeat',
|
|---|
| 115 | 'inherit',
|
|---|
| 116 | 'repeat',
|
|---|
| 117 | 'repeat-x',
|
|---|
| 118 | 'repeat-y',
|
|---|
| 119 | 'round',
|
|---|
| 120 | 'space'
|
|---|
| 121 | ],
|
|---|
| 122 | 'background-size': [
|
|---|
| 123 | 'auto',
|
|---|
| 124 | 'cover',
|
|---|
| 125 | 'contain'
|
|---|
| 126 | ],
|
|---|
| 127 | 'border-collapse': [
|
|---|
| 128 | 'collapse',
|
|---|
| 129 | 'inherit',
|
|---|
| 130 | 'separate'
|
|---|
| 131 | ],
|
|---|
| 132 | bottom: [
|
|---|
| 133 | 'auto'
|
|---|
| 134 | ],
|
|---|
| 135 | clear: [
|
|---|
| 136 | 'both',
|
|---|
| 137 | 'left',
|
|---|
| 138 | 'none',
|
|---|
| 139 | 'right'
|
|---|
| 140 | ],
|
|---|
| 141 | color: [
|
|---|
| 142 | 'transparent'
|
|---|
| 143 | ],
|
|---|
| 144 | cursor: [
|
|---|
| 145 | 'all-scroll',
|
|---|
| 146 | 'auto',
|
|---|
| 147 | 'col-resize',
|
|---|
| 148 | 'crosshair',
|
|---|
| 149 | 'default',
|
|---|
| 150 | 'e-resize',
|
|---|
| 151 | 'help',
|
|---|
| 152 | 'move',
|
|---|
| 153 | 'n-resize',
|
|---|
| 154 | 'ne-resize',
|
|---|
| 155 | 'no-drop',
|
|---|
| 156 | 'not-allowed',
|
|---|
| 157 | 'nw-resize',
|
|---|
| 158 | 'pointer',
|
|---|
| 159 | 'progress',
|
|---|
| 160 | 'row-resize',
|
|---|
| 161 | 's-resize',
|
|---|
| 162 | 'se-resize',
|
|---|
| 163 | 'sw-resize',
|
|---|
| 164 | 'text',
|
|---|
| 165 | 'vertical-text',
|
|---|
| 166 | 'w-resize',
|
|---|
| 167 | 'wait'
|
|---|
| 168 | ],
|
|---|
| 169 | display: [
|
|---|
| 170 | 'block',
|
|---|
| 171 | 'inline',
|
|---|
| 172 | 'inline-block',
|
|---|
| 173 | 'inline-table',
|
|---|
| 174 | 'list-item',
|
|---|
| 175 | 'none',
|
|---|
| 176 | 'table',
|
|---|
| 177 | 'table-caption',
|
|---|
| 178 | 'table-cell',
|
|---|
| 179 | 'table-column',
|
|---|
| 180 | 'table-column-group',
|
|---|
| 181 | 'table-footer-group',
|
|---|
| 182 | 'table-header-group',
|
|---|
| 183 | 'table-row',
|
|---|
| 184 | 'table-row-group'
|
|---|
| 185 | ],
|
|---|
| 186 | float: [
|
|---|
| 187 | 'left',
|
|---|
| 188 | 'none',
|
|---|
| 189 | 'right'
|
|---|
| 190 | ],
|
|---|
| 191 | left: [
|
|---|
| 192 | 'auto'
|
|---|
| 193 | ],
|
|---|
| 194 | font: [
|
|---|
| 195 | 'caption',
|
|---|
| 196 | 'icon',
|
|---|
| 197 | 'menu',
|
|---|
| 198 | 'message-box',
|
|---|
| 199 | 'small-caption',
|
|---|
| 200 | 'status-bar',
|
|---|
| 201 | 'unset'
|
|---|
| 202 | ],
|
|---|
| 203 | 'font-size': [
|
|---|
| 204 | 'large',
|
|---|
| 205 | 'larger',
|
|---|
| 206 | 'medium',
|
|---|
| 207 | 'small',
|
|---|
| 208 | 'smaller',
|
|---|
| 209 | 'x-large',
|
|---|
| 210 | 'x-small',
|
|---|
| 211 | 'xx-large',
|
|---|
| 212 | 'xx-small'
|
|---|
| 213 | ],
|
|---|
| 214 | 'font-stretch': [
|
|---|
| 215 | 'condensed',
|
|---|
| 216 | 'expanded',
|
|---|
| 217 | 'extra-condensed',
|
|---|
| 218 | 'extra-expanded',
|
|---|
| 219 | 'normal',
|
|---|
| 220 | 'semi-condensed',
|
|---|
| 221 | 'semi-expanded',
|
|---|
| 222 | 'ultra-condensed',
|
|---|
| 223 | 'ultra-expanded'
|
|---|
| 224 | ],
|
|---|
| 225 | 'font-style': [
|
|---|
| 226 | 'italic',
|
|---|
| 227 | 'normal',
|
|---|
| 228 | 'oblique'
|
|---|
| 229 | ],
|
|---|
| 230 | 'font-variant': [
|
|---|
| 231 | 'normal',
|
|---|
| 232 | 'small-caps'
|
|---|
| 233 | ],
|
|---|
| 234 | 'font-weight': [
|
|---|
| 235 | '100',
|
|---|
| 236 | '200',
|
|---|
| 237 | '300',
|
|---|
| 238 | '400',
|
|---|
| 239 | '500',
|
|---|
| 240 | '600',
|
|---|
| 241 | '700',
|
|---|
| 242 | '800',
|
|---|
| 243 | '900',
|
|---|
| 244 | 'bold',
|
|---|
| 245 | 'bolder',
|
|---|
| 246 | 'lighter',
|
|---|
| 247 | 'normal'
|
|---|
| 248 | ],
|
|---|
| 249 | 'line-height': [
|
|---|
| 250 | 'normal'
|
|---|
| 251 | ],
|
|---|
| 252 | 'list-style-position': [
|
|---|
| 253 | 'inside',
|
|---|
| 254 | 'outside'
|
|---|
| 255 | ],
|
|---|
| 256 | 'list-style-type': [
|
|---|
| 257 | 'armenian',
|
|---|
| 258 | 'circle',
|
|---|
| 259 | 'decimal',
|
|---|
| 260 | 'decimal-leading-zero',
|
|---|
| 261 | 'disc',
|
|---|
| 262 | 'decimal|disc', // this is the default value of list-style-type, see comment in configuration.js
|
|---|
| 263 | 'georgian',
|
|---|
| 264 | 'lower-alpha',
|
|---|
| 265 | 'lower-greek',
|
|---|
| 266 | 'lower-latin',
|
|---|
| 267 | 'lower-roman',
|
|---|
| 268 | 'none',
|
|---|
| 269 | 'square',
|
|---|
| 270 | 'upper-alpha',
|
|---|
| 271 | 'upper-latin',
|
|---|
| 272 | 'upper-roman'
|
|---|
| 273 | ],
|
|---|
| 274 | overflow: [
|
|---|
| 275 | 'auto',
|
|---|
| 276 | 'hidden',
|
|---|
| 277 | 'scroll',
|
|---|
| 278 | 'visible'
|
|---|
| 279 | ],
|
|---|
| 280 | position: [
|
|---|
| 281 | 'absolute',
|
|---|
| 282 | 'fixed',
|
|---|
| 283 | 'relative',
|
|---|
| 284 | 'static'
|
|---|
| 285 | ],
|
|---|
| 286 | right: [
|
|---|
| 287 | 'auto'
|
|---|
| 288 | ],
|
|---|
| 289 | 'text-align': [
|
|---|
| 290 | 'center',
|
|---|
| 291 | 'justify',
|
|---|
| 292 | 'left',
|
|---|
| 293 | 'left|right', // this is the default value of list-style-type, see comment in configuration.js
|
|---|
| 294 | 'right'
|
|---|
| 295 | ],
|
|---|
| 296 | 'text-decoration': [
|
|---|
| 297 | 'line-through',
|
|---|
| 298 | 'none',
|
|---|
| 299 | 'overline',
|
|---|
| 300 | 'underline'
|
|---|
| 301 | ],
|
|---|
| 302 | 'text-overflow': [
|
|---|
| 303 | 'clip',
|
|---|
| 304 | 'ellipsis'
|
|---|
| 305 | ],
|
|---|
| 306 | top: [
|
|---|
| 307 | 'auto'
|
|---|
| 308 | ],
|
|---|
| 309 | 'vertical-align': [
|
|---|
| 310 | 'baseline',
|
|---|
| 311 | 'bottom',
|
|---|
| 312 | 'middle',
|
|---|
| 313 | 'sub',
|
|---|
| 314 | 'super',
|
|---|
| 315 | 'text-bottom',
|
|---|
| 316 | 'text-top',
|
|---|
| 317 | 'top'
|
|---|
| 318 | ],
|
|---|
| 319 | visibility: [
|
|---|
| 320 | 'collapse',
|
|---|
| 321 | 'hidden',
|
|---|
| 322 | 'visible'
|
|---|
| 323 | ],
|
|---|
| 324 | 'white-space': [
|
|---|
| 325 | 'normal',
|
|---|
| 326 | 'nowrap',
|
|---|
| 327 | 'pre'
|
|---|
| 328 | ],
|
|---|
| 329 | width: [
|
|---|
| 330 | 'inherit',
|
|---|
| 331 | 'initial',
|
|---|
| 332 | 'medium',
|
|---|
| 333 | 'thick',
|
|---|
| 334 | 'thin'
|
|---|
| 335 | ]
|
|---|
| 336 | };
|
|---|
| 337 |
|
|---|
| 338 | var Units = [
|
|---|
| 339 | '%',
|
|---|
| 340 | 'ch',
|
|---|
| 341 | 'cm',
|
|---|
| 342 | 'em',
|
|---|
| 343 | 'ex',
|
|---|
| 344 | 'in',
|
|---|
| 345 | 'mm',
|
|---|
| 346 | 'pc',
|
|---|
| 347 | 'pt',
|
|---|
| 348 | 'px',
|
|---|
| 349 | 'rem',
|
|---|
| 350 | 'vh',
|
|---|
| 351 | 'vm',
|
|---|
| 352 | 'vmax',
|
|---|
| 353 | 'vmin',
|
|---|
| 354 | 'vw'
|
|---|
| 355 | ];
|
|---|
| 356 |
|
|---|
| 357 | function isColor(value) {
|
|---|
| 358 | return value != 'auto'
|
|---|
| 359 | && (
|
|---|
| 360 | isKeyword('color')(value)
|
|---|
| 361 | || isHexColor(value)
|
|---|
| 362 | || isColorFunction(value)
|
|---|
| 363 | || isNamedEntity(value)
|
|---|
| 364 | );
|
|---|
| 365 | }
|
|---|
| 366 |
|
|---|
| 367 | function isColorFunction(value) {
|
|---|
| 368 | return isRgbColor(value) || isHslColor(value);
|
|---|
| 369 | }
|
|---|
| 370 |
|
|---|
| 371 | function isDynamicUnit(value) {
|
|---|
| 372 | return calcRegex.test(value);
|
|---|
| 373 | }
|
|---|
| 374 |
|
|---|
| 375 | function isFunction(value) {
|
|---|
| 376 | return functionAnyRegex.test(value);
|
|---|
| 377 | }
|
|---|
| 378 |
|
|---|
| 379 | function isHexColor(value) {
|
|---|
| 380 | return threeValueColorRegex.test(value)
|
|---|
| 381 | || fourValueColorRegex.test(value)
|
|---|
| 382 | || sixValueColorRegex.test(value)
|
|---|
| 383 | || eightValueColorRegex.test(value);
|
|---|
| 384 | }
|
|---|
| 385 |
|
|---|
| 386 | function isHslColor(value) {
|
|---|
| 387 | return hslColorRegex.test(value) || hslColorWithSpacesRegex.test(value);
|
|---|
| 388 | }
|
|---|
| 389 |
|
|---|
| 390 | function isHexAlphaColor(value) {
|
|---|
| 391 | return hexAlphaColorRegex.test(value);
|
|---|
| 392 | }
|
|---|
| 393 |
|
|---|
| 394 | function isIdentifier(value) {
|
|---|
| 395 | return identifierRegex.test(value);
|
|---|
| 396 | }
|
|---|
| 397 |
|
|---|
| 398 | function isQuotedText(value) {
|
|---|
| 399 | return quotedTextRegex.test(value);
|
|---|
| 400 | }
|
|---|
| 401 |
|
|---|
| 402 | function isImage(value) {
|
|---|
| 403 | return value == 'none' || value == 'inherit' || isUrl(value);
|
|---|
| 404 | }
|
|---|
| 405 |
|
|---|
| 406 | function isKeyword(propertyName) {
|
|---|
| 407 | return function(value) {
|
|---|
| 408 | return Keywords[propertyName].indexOf(value) > -1;
|
|---|
| 409 | };
|
|---|
| 410 | }
|
|---|
| 411 |
|
|---|
| 412 | function isNamedEntity(value) {
|
|---|
| 413 | return namedEntityRegex.test(value);
|
|---|
| 414 | }
|
|---|
| 415 |
|
|---|
| 416 | function isNumber(value) {
|
|---|
| 417 | return scanForNumber(value) == value.length;
|
|---|
| 418 | }
|
|---|
| 419 |
|
|---|
| 420 | function isRgbColor(value) {
|
|---|
| 421 | return rgbColorRegex.test(value) || rgbColorWithSpacesRegex.test(value);
|
|---|
| 422 | }
|
|---|
| 423 |
|
|---|
| 424 | function isPrefixed(value) {
|
|---|
| 425 | return prefixRegex.test(value);
|
|---|
| 426 | }
|
|---|
| 427 |
|
|---|
| 428 | function isPositiveNumber(value) {
|
|---|
| 429 | return isNumber(value)
|
|---|
| 430 | && parseFloat(value) >= 0;
|
|---|
| 431 | }
|
|---|
| 432 |
|
|---|
| 433 | function isVariable(value) {
|
|---|
| 434 | return variableRegex.test(value);
|
|---|
| 435 | }
|
|---|
| 436 |
|
|---|
| 437 | function isTime(value) {
|
|---|
| 438 | var numberUpTo = scanForNumber(value);
|
|---|
| 439 |
|
|---|
| 440 | return numberUpTo == value.length && parseInt(value) === 0
|
|---|
| 441 | || numberUpTo > -1 && validTimeUnits.indexOf(value.slice(numberUpTo + 1)) > -1
|
|---|
| 442 | || isCalculatedTime(value);
|
|---|
| 443 | }
|
|---|
| 444 |
|
|---|
| 445 | function isCalculatedTime(value) {
|
|---|
| 446 | return isFunction(value) && timeUnitPattern.test(value);
|
|---|
| 447 | }
|
|---|
| 448 |
|
|---|
| 449 | function isTimingFunction() {
|
|---|
| 450 | var isTimingFunctionKeyword = isKeyword('*-timing-function');
|
|---|
| 451 |
|
|---|
| 452 | return function(value) {
|
|---|
| 453 | return isTimingFunctionKeyword(value) || timingFunctionRegex.test(value);
|
|---|
| 454 | };
|
|---|
| 455 | }
|
|---|
| 456 |
|
|---|
| 457 | function isUnit(validUnits, value) {
|
|---|
| 458 | var numberUpTo = scanForNumber(value);
|
|---|
| 459 |
|
|---|
| 460 | return numberUpTo == value.length && parseInt(value) === 0
|
|---|
| 461 | || numberUpTo > -1 && validUnits.indexOf(value.slice(numberUpTo + 1).toLowerCase()) > -1
|
|---|
| 462 | || value == 'auto'
|
|---|
| 463 | || value == 'inherit';
|
|---|
| 464 | }
|
|---|
| 465 |
|
|---|
| 466 | function isUrl(value) {
|
|---|
| 467 | return urlRegex.test(value);
|
|---|
| 468 | }
|
|---|
| 469 |
|
|---|
| 470 | function isZIndex(value) {
|
|---|
| 471 | return value == 'auto'
|
|---|
| 472 | || isNumber(value)
|
|---|
| 473 | || isKeyword('^')(value);
|
|---|
| 474 | }
|
|---|
| 475 |
|
|---|
| 476 | function scanForNumber(value) {
|
|---|
| 477 | var hasDot = false;
|
|---|
| 478 | var hasSign = false;
|
|---|
| 479 | var character;
|
|---|
| 480 | var i, l;
|
|---|
| 481 |
|
|---|
| 482 | for (i = 0, l = value.length; i < l; i++) {
|
|---|
| 483 | character = value[i];
|
|---|
| 484 |
|
|---|
| 485 | if (i === 0 && (character == PLUS_SIGN || character == MINUS_SIGN)) {
|
|---|
| 486 | hasSign = true;
|
|---|
| 487 | } else if (i > 0 && hasSign && (character == PLUS_SIGN || character == MINUS_SIGN)) {
|
|---|
| 488 | return i - 1;
|
|---|
| 489 | } else if (character == DECIMAL_DOT && !hasDot) {
|
|---|
| 490 | hasDot = true;
|
|---|
| 491 | } else if (character == DECIMAL_DOT && hasDot) {
|
|---|
| 492 | return i - 1;
|
|---|
| 493 | } else if (decimalRegex.test(character)) {
|
|---|
| 494 | continue;
|
|---|
| 495 | } else {
|
|---|
| 496 | return i - 1;
|
|---|
| 497 | }
|
|---|
| 498 | }
|
|---|
| 499 |
|
|---|
| 500 | return i;
|
|---|
| 501 | }
|
|---|
| 502 |
|
|---|
| 503 | function validator(compatibility) {
|
|---|
| 504 | var validUnits = Units.slice(0).filter(function(value) {
|
|---|
| 505 | return !(value in compatibility.units) || compatibility.units[value] === true;
|
|---|
| 506 | });
|
|---|
| 507 |
|
|---|
| 508 | if (compatibility.customUnits.rpx) {
|
|---|
| 509 | validUnits.push('rpx');
|
|---|
| 510 | }
|
|---|
| 511 |
|
|---|
| 512 | return {
|
|---|
| 513 | colorOpacity: compatibility.colors.opacity,
|
|---|
| 514 | colorHexAlpha: compatibility.colors.hexAlpha,
|
|---|
| 515 | isAnimationDirectionKeyword: isKeyword('animation-direction'),
|
|---|
| 516 | isAnimationFillModeKeyword: isKeyword('animation-fill-mode'),
|
|---|
| 517 | isAnimationIterationCountKeyword: isKeyword('animation-iteration-count'),
|
|---|
| 518 | isAnimationNameKeyword: isKeyword('animation-name'),
|
|---|
| 519 | isAnimationPlayStateKeyword: isKeyword('animation-play-state'),
|
|---|
| 520 | isTimingFunction: isTimingFunction(),
|
|---|
| 521 | isBackgroundAttachmentKeyword: isKeyword('background-attachment'),
|
|---|
| 522 | isBackgroundClipKeyword: isKeyword('background-clip'),
|
|---|
| 523 | isBackgroundOriginKeyword: isKeyword('background-origin'),
|
|---|
| 524 | isBackgroundPositionKeyword: isKeyword('background-position'),
|
|---|
| 525 | isBackgroundRepeatKeyword: isKeyword('background-repeat'),
|
|---|
| 526 | isBackgroundSizeKeyword: isKeyword('background-size'),
|
|---|
| 527 | isColor: isColor,
|
|---|
| 528 | isColorFunction: isColorFunction,
|
|---|
| 529 | isDynamicUnit: isDynamicUnit,
|
|---|
| 530 | isFontKeyword: isKeyword('font'),
|
|---|
| 531 | isFontSizeKeyword: isKeyword('font-size'),
|
|---|
| 532 | isFontStretchKeyword: isKeyword('font-stretch'),
|
|---|
| 533 | isFontStyleKeyword: isKeyword('font-style'),
|
|---|
| 534 | isFontVariantKeyword: isKeyword('font-variant'),
|
|---|
| 535 | isFontWeightKeyword: isKeyword('font-weight'),
|
|---|
| 536 | isFunction: isFunction,
|
|---|
| 537 | isGlobal: isKeyword('^'),
|
|---|
| 538 | isHexAlphaColor: isHexAlphaColor,
|
|---|
| 539 | isHslColor: isHslColor,
|
|---|
| 540 | isIdentifier: isIdentifier,
|
|---|
| 541 | isImage: isImage,
|
|---|
| 542 | isKeyword: isKeyword,
|
|---|
| 543 | isLineHeightKeyword: isKeyword('line-height'),
|
|---|
| 544 | isListStylePositionKeyword: isKeyword('list-style-position'),
|
|---|
| 545 | isListStyleTypeKeyword: isKeyword('list-style-type'),
|
|---|
| 546 | isNumber: isNumber,
|
|---|
| 547 | isPrefixed: isPrefixed,
|
|---|
| 548 | isPositiveNumber: isPositiveNumber,
|
|---|
| 549 | isQuotedText: isQuotedText,
|
|---|
| 550 | isRgbColor: isRgbColor,
|
|---|
| 551 | isStyleKeyword: isKeyword('*-style'),
|
|---|
| 552 | isTime: isTime,
|
|---|
| 553 | isUnit: isUnit.bind(null, validUnits),
|
|---|
| 554 | isUrl: isUrl,
|
|---|
| 555 | isVariable: isVariable,
|
|---|
| 556 | isWidth: isKeyword('width'),
|
|---|
| 557 | isZIndex: isZIndex
|
|---|
| 558 | };
|
|---|
| 559 | }
|
|---|
| 560 |
|
|---|
| 561 | module.exports = validator;
|
|---|