|
|
@@ -33,7 +33,7 @@ this.parseSrcset = (() => {
|
|
|
}
|
|
|
|
|
|
function collectCharacters(regEx) {
|
|
|
- var chars,
|
|
|
+ let chars,
|
|
|
match = regEx.exec(input.substring(pos));
|
|
|
if (match) {
|
|
|
chars = match[0];
|
|
|
@@ -42,36 +42,30 @@ this.parseSrcset = (() => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- var inputLength = input.length,
|
|
|
-
|
|
|
- // (Don"t use \s, to avoid matching non-breaking space)
|
|
|
- /* eslint-disable no-control-regex */
|
|
|
- regexLeadingSpaces = /^[ \t\n\r\u000c]+/, //
|
|
|
- regexLeadingCommasOrSpaces = /^[, \t\n\r\u000c]+/,
|
|
|
- regexLeadingNotSpaces = /^[^ \t\n\r\u000c]+/,
|
|
|
- regexTrailingCommas = /[,]+$/,
|
|
|
- regexNonNegativeInteger = /^\d+$/,
|
|
|
- /* eslint-enable no-control-regex */
|
|
|
-
|
|
|
- // ( Positive or negative or unsigned integers or decimals, without or without exponents.
|
|
|
- // Must include at least one digit.
|
|
|
- // According to spec tests any decimal point must be followed by a digit.
|
|
|
- // No leading plus sign is allowed.)
|
|
|
- // https://html.spec.whatwg.org/multipage/infrastructure.html#valid-floating-point-number
|
|
|
- regexFloatingPoint = /^-?(?:[0-9]+|[0-9]*\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/,
|
|
|
-
|
|
|
- url,
|
|
|
- descriptors,
|
|
|
- currentDescriptor,
|
|
|
- state,
|
|
|
- c,
|
|
|
-
|
|
|
+ const inputLength = input.length;
|
|
|
+
|
|
|
+ // (Don"t use \s, to avoid matching non-breaking space)
|
|
|
+ /* eslint-disable no-control-regex */
|
|
|
+ const regexLeadingSpaces = /^[ \t\n\r\u000c]+/;
|
|
|
+ const regexLeadingCommasOrSpaces = /^[, \t\n\r\u000c]+/;
|
|
|
+ const regexLeadingNotSpaces = /^[^ \t\n\r\u000c]+/;
|
|
|
+ const regexTrailingCommas = /[,]+$/;
|
|
|
+ const regexNonNegativeInteger = /^\d+$/;
|
|
|
+ /* eslint-enable no-control-regex */
|
|
|
+
|
|
|
+ // ( Positive or negative or unsigned integers or decimals, without or without exponents.
|
|
|
+ // Must include at least one digit.
|
|
|
+ // According to spec tests any decimal point must be followed by a digit.
|
|
|
+ // No leading plus sign is allowed.)
|
|
|
+ // https://html.spec.whatwg.org/multipage/infrastructure.html#valid-floating-point-number
|
|
|
+ const regexFloatingPoint = /^-?(?:[0-9]+|[0-9]*\.[0-9]+)(?:[eE][+-]?[0-9]+)?$/;
|
|
|
+
|
|
|
+ let url, descriptors, currentDescriptor, state, c,
|
|
|
// 2. Let position be a pointer into input, initially pointing at the start
|
|
|
// of the string.
|
|
|
- pos = 0,
|
|
|
-
|
|
|
- // 3. Let candidates be an initially empty source set.
|
|
|
- candidates = [];
|
|
|
+ pos = 0;
|
|
|
+ // 3. Let candidates be an initially empty source set.
|
|
|
+ const candidates = [];
|
|
|
|
|
|
// 4. Splitting loop: Collect a sequence of characters that are space
|
|
|
// characters or U+002C COMMA characters. If any U+002C COMMA characters
|
|
|
@@ -240,14 +234,14 @@ this.parseSrcset = (() => {
|
|
|
function parseDescriptors() {
|
|
|
|
|
|
// 9. Descriptor parser: Let error be no.
|
|
|
- var pError = false,
|
|
|
+ let pError = false,
|
|
|
|
|
|
// 10. Let width be absent.
|
|
|
// 11. Let density be absent.
|
|
|
// 12. Let future-compat-h be absent. (We"re implementing it now as h)
|
|
|
w, d, h, i,
|
|
|
- candidate = {},
|
|
|
desc, lastChar, value, intVal, floatVal;
|
|
|
+ const candidate = {};
|
|
|
|
|
|
// 13. For each descriptor in descriptors, run the appropriate set of steps
|
|
|
// from the following list:
|