Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93

Warning: Undefined array key "page_file_edit_line" in /home/sportsfever/public_html/filemanger/edit_text_line.php on line 32
/home/sportsfe.../httpdocs/clone/wp-inclu.../js/dist
File: blocks.js
type: "Comment" /* Comment */,
[11500] Fix | Delete
chars: ''
[11501] Fix | Delete
});
[11502] Fix | Delete
};
[11503] Fix | Delete
Tokenizer.prototype.appendToCommentData = function (char) {
[11504] Fix | Delete
this.current("Comment" /* Comment */).chars += char;
[11505] Fix | Delete
};
[11506] Fix | Delete
Tokenizer.prototype.finishComment = function () {
[11507] Fix | Delete
this.addLocInfo();
[11508] Fix | Delete
};
[11509] Fix | Delete
// Tags - basic
[11510] Fix | Delete
Tokenizer.prototype.tagOpen = function () { };
[11511] Fix | Delete
Tokenizer.prototype.beginStartTag = function () {
[11512] Fix | Delete
this.push({
[11513] Fix | Delete
type: "StartTag" /* StartTag */,
[11514] Fix | Delete
tagName: '',
[11515] Fix | Delete
attributes: [],
[11516] Fix | Delete
selfClosing: false
[11517] Fix | Delete
});
[11518] Fix | Delete
};
[11519] Fix | Delete
Tokenizer.prototype.beginEndTag = function () {
[11520] Fix | Delete
this.push({
[11521] Fix | Delete
type: "EndTag" /* EndTag */,
[11522] Fix | Delete
tagName: ''
[11523] Fix | Delete
});
[11524] Fix | Delete
};
[11525] Fix | Delete
Tokenizer.prototype.finishTag = function () {
[11526] Fix | Delete
this.addLocInfo();
[11527] Fix | Delete
};
[11528] Fix | Delete
Tokenizer.prototype.markTagAsSelfClosing = function () {
[11529] Fix | Delete
this.current("StartTag" /* StartTag */).selfClosing = true;
[11530] Fix | Delete
};
[11531] Fix | Delete
// Tags - name
[11532] Fix | Delete
Tokenizer.prototype.appendToTagName = function (char) {
[11533] Fix | Delete
this.current("StartTag" /* StartTag */, "EndTag" /* EndTag */).tagName += char;
[11534] Fix | Delete
};
[11535] Fix | Delete
// Tags - attributes
[11536] Fix | Delete
Tokenizer.prototype.beginAttribute = function () {
[11537] Fix | Delete
this._currentAttribute = ['', '', false];
[11538] Fix | Delete
};
[11539] Fix | Delete
Tokenizer.prototype.appendToAttributeName = function (char) {
[11540] Fix | Delete
this.currentAttribute()[0] += char;
[11541] Fix | Delete
};
[11542] Fix | Delete
Tokenizer.prototype.beginAttributeValue = function (isQuoted) {
[11543] Fix | Delete
this.currentAttribute()[2] = isQuoted;
[11544] Fix | Delete
};
[11545] Fix | Delete
Tokenizer.prototype.appendToAttributeValue = function (char) {
[11546] Fix | Delete
this.currentAttribute()[1] += char;
[11547] Fix | Delete
};
[11548] Fix | Delete
Tokenizer.prototype.finishAttributeValue = function () {
[11549] Fix | Delete
this.current("StartTag" /* StartTag */).attributes.push(this._currentAttribute);
[11550] Fix | Delete
};
[11551] Fix | Delete
Tokenizer.prototype.reportSyntaxError = function (message) {
[11552] Fix | Delete
this.current().syntaxError = message;
[11553] Fix | Delete
};
[11554] Fix | Delete
return Tokenizer;
[11555] Fix | Delete
}());
[11556] Fix | Delete
[11557] Fix | Delete
function tokenize(input, options) {
[11558] Fix | Delete
var tokenizer = new Tokenizer(new EntityParser(namedCharRefs), options);
[11559] Fix | Delete
return tokenizer.tokenize(input);
[11560] Fix | Delete
}
[11561] Fix | Delete
[11562] Fix | Delete
[11563] Fix | Delete
[11564] Fix | Delete
// EXTERNAL MODULE: ./node_modules/fast-deep-equal/es6/index.js
[11565] Fix | Delete
var es6 = __webpack_require__(7734);
[11566] Fix | Delete
var es6_default = /*#__PURE__*/__webpack_require__.n(es6);
[11567] Fix | Delete
;// CONCATENATED MODULE: external ["wp","htmlEntities"]
[11568] Fix | Delete
const external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
[11569] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/validation/logger.js
[11570] Fix | Delete
/**
[11571] Fix | Delete
* @typedef LoggerItem
[11572] Fix | Delete
* @property {Function} log Which logger recorded the message
[11573] Fix | Delete
* @property {Array<any>} args White arguments were supplied to the logger
[11574] Fix | Delete
*/
[11575] Fix | Delete
[11576] Fix | Delete
function createLogger() {
[11577] Fix | Delete
/**
[11578] Fix | Delete
* Creates a log handler with block validation prefix.
[11579] Fix | Delete
*
[11580] Fix | Delete
* @param {Function} logger Original logger function.
[11581] Fix | Delete
*
[11582] Fix | Delete
* @return {Function} Augmented logger function.
[11583] Fix | Delete
*/
[11584] Fix | Delete
function createLogHandler(logger) {
[11585] Fix | Delete
let log = (message, ...args) => logger('Block validation: ' + message, ...args);
[11586] Fix | Delete
[11587] Fix | Delete
// In test environments, pre-process string substitutions to improve
[11588] Fix | Delete
// readability of error messages. We'd prefer to avoid pulling in this
[11589] Fix | Delete
// dependency in runtime environments, and it can be dropped by a combo
[11590] Fix | Delete
// of Webpack env substitution + UglifyJS dead code elimination.
[11591] Fix | Delete
if (false) {}
[11592] Fix | Delete
return log;
[11593] Fix | Delete
}
[11594] Fix | Delete
return {
[11595] Fix | Delete
// eslint-disable-next-line no-console
[11596] Fix | Delete
error: createLogHandler(console.error),
[11597] Fix | Delete
// eslint-disable-next-line no-console
[11598] Fix | Delete
warning: createLogHandler(console.warn),
[11599] Fix | Delete
getItems() {
[11600] Fix | Delete
return [];
[11601] Fix | Delete
}
[11602] Fix | Delete
};
[11603] Fix | Delete
}
[11604] Fix | Delete
function createQueuedLogger() {
[11605] Fix | Delete
/**
[11606] Fix | Delete
* The list of enqueued log actions to print.
[11607] Fix | Delete
*
[11608] Fix | Delete
* @type {Array<LoggerItem>}
[11609] Fix | Delete
*/
[11610] Fix | Delete
const queue = [];
[11611] Fix | Delete
const logger = createLogger();
[11612] Fix | Delete
return {
[11613] Fix | Delete
error(...args) {
[11614] Fix | Delete
queue.push({
[11615] Fix | Delete
log: logger.error,
[11616] Fix | Delete
args
[11617] Fix | Delete
});
[11618] Fix | Delete
},
[11619] Fix | Delete
warning(...args) {
[11620] Fix | Delete
queue.push({
[11621] Fix | Delete
log: logger.warning,
[11622] Fix | Delete
args
[11623] Fix | Delete
});
[11624] Fix | Delete
},
[11625] Fix | Delete
getItems() {
[11626] Fix | Delete
return queue;
[11627] Fix | Delete
}
[11628] Fix | Delete
};
[11629] Fix | Delete
}
[11630] Fix | Delete
[11631] Fix | Delete
;// CONCATENATED MODULE: ./node_modules/@wordpress/blocks/build-module/api/validation/index.js
[11632] Fix | Delete
/**
[11633] Fix | Delete
* External dependencies
[11634] Fix | Delete
*/
[11635] Fix | Delete
[11636] Fix | Delete
[11637] Fix | Delete
[11638] Fix | Delete
/**
[11639] Fix | Delete
* WordPress dependencies
[11640] Fix | Delete
*/
[11641] Fix | Delete
[11642] Fix | Delete
[11643] Fix | Delete
[11644] Fix | Delete
/**
[11645] Fix | Delete
* Internal dependencies
[11646] Fix | Delete
*/
[11647] Fix | Delete
[11648] Fix | Delete
[11649] Fix | Delete
[11650] Fix | Delete
[11651] Fix | Delete
[11652] Fix | Delete
/** @typedef {import('../parser').WPBlock} WPBlock */
[11653] Fix | Delete
/** @typedef {import('../registration').WPBlockType} WPBlockType */
[11654] Fix | Delete
/** @typedef {import('./logger').LoggerItem} LoggerItem */
[11655] Fix | Delete
[11656] Fix | Delete
const identity = x => x;
[11657] Fix | Delete
[11658] Fix | Delete
/**
[11659] Fix | Delete
* Globally matches any consecutive whitespace
[11660] Fix | Delete
*
[11661] Fix | Delete
* @type {RegExp}
[11662] Fix | Delete
*/
[11663] Fix | Delete
const REGEXP_WHITESPACE = /[\t\n\r\v\f ]+/g;
[11664] Fix | Delete
[11665] Fix | Delete
/**
[11666] Fix | Delete
* Matches a string containing only whitespace
[11667] Fix | Delete
*
[11668] Fix | Delete
* @type {RegExp}
[11669] Fix | Delete
*/
[11670] Fix | Delete
const REGEXP_ONLY_WHITESPACE = /^[\t\n\r\v\f ]*$/;
[11671] Fix | Delete
[11672] Fix | Delete
/**
[11673] Fix | Delete
* Matches a CSS URL type value
[11674] Fix | Delete
*
[11675] Fix | Delete
* @type {RegExp}
[11676] Fix | Delete
*/
[11677] Fix | Delete
const REGEXP_STYLE_URL_TYPE = /^url\s*\(['"\s]*(.*?)['"\s]*\)$/;
[11678] Fix | Delete
[11679] Fix | Delete
/**
[11680] Fix | Delete
* Boolean attributes are attributes whose presence as being assigned is
[11681] Fix | Delete
* meaningful, even if only empty.
[11682] Fix | Delete
*
[11683] Fix | Delete
* See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#boolean-attributes
[11684] Fix | Delete
* Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3
[11685] Fix | Delete
*
[11686] Fix | Delete
* Object.keys( Array.from( document.querySelectorAll( '#attributes-1 > tbody > tr' ) )
[11687] Fix | Delete
* .filter( ( tr ) => tr.lastChild.textContent.indexOf( 'Boolean attribute' ) !== -1 )
[11688] Fix | Delete
* .reduce( ( result, tr ) => Object.assign( result, {
[11689] Fix | Delete
* [ tr.firstChild.textContent.trim() ]: true
[11690] Fix | Delete
* } ), {} ) ).sort();
[11691] Fix | Delete
*
[11692] Fix | Delete
* @type {Array}
[11693] Fix | Delete
*/
[11694] Fix | Delete
const BOOLEAN_ATTRIBUTES = ['allowfullscreen', 'allowpaymentrequest', 'allowusermedia', 'async', 'autofocus', 'autoplay', 'checked', 'controls', 'default', 'defer', 'disabled', 'download', 'formnovalidate', 'hidden', 'ismap', 'itemscope', 'loop', 'multiple', 'muted', 'nomodule', 'novalidate', 'open', 'playsinline', 'readonly', 'required', 'reversed', 'selected', 'typemustmatch'];
[11695] Fix | Delete
[11696] Fix | Delete
/**
[11697] Fix | Delete
* Enumerated attributes are attributes which must be of a specific value form.
[11698] Fix | Delete
* Like boolean attributes, these are meaningful if specified, even if not of a
[11699] Fix | Delete
* valid enumerated value.
[11700] Fix | Delete
*
[11701] Fix | Delete
* See: https://html.spec.whatwg.org/multipage/common-microsyntaxes.html#enumerated-attribute
[11702] Fix | Delete
* Extracted from: https://html.spec.whatwg.org/multipage/indices.html#attributes-3
[11703] Fix | Delete
*
[11704] Fix | Delete
* Object.keys( Array.from( document.querySelectorAll( '#attributes-1 > tbody > tr' ) )
[11705] Fix | Delete
* .filter( ( tr ) => /^("(.+?)";?\s*)+/.test( tr.lastChild.textContent.trim() ) )
[11706] Fix | Delete
* .reduce( ( result, tr ) => Object.assign( result, {
[11707] Fix | Delete
* [ tr.firstChild.textContent.trim() ]: true
[11708] Fix | Delete
* } ), {} ) ).sort();
[11709] Fix | Delete
*
[11710] Fix | Delete
* @type {Array}
[11711] Fix | Delete
*/
[11712] Fix | Delete
const ENUMERATED_ATTRIBUTES = ['autocapitalize', 'autocomplete', 'charset', 'contenteditable', 'crossorigin', 'decoding', 'dir', 'draggable', 'enctype', 'formenctype', 'formmethod', 'http-equiv', 'inputmode', 'kind', 'method', 'preload', 'scope', 'shape', 'spellcheck', 'translate', 'type', 'wrap'];
[11713] Fix | Delete
[11714] Fix | Delete
/**
[11715] Fix | Delete
* Meaningful attributes are those who cannot be safely ignored when omitted in
[11716] Fix | Delete
* one HTML markup string and not another.
[11717] Fix | Delete
*
[11718] Fix | Delete
* @type {Array}
[11719] Fix | Delete
*/
[11720] Fix | Delete
const MEANINGFUL_ATTRIBUTES = [...BOOLEAN_ATTRIBUTES, ...ENUMERATED_ATTRIBUTES];
[11721] Fix | Delete
[11722] Fix | Delete
/**
[11723] Fix | Delete
* Array of functions which receive a text string on which to apply normalizing
[11724] Fix | Delete
* behavior for consideration in text token equivalence, carefully ordered from
[11725] Fix | Delete
* least-to-most expensive operations.
[11726] Fix | Delete
*
[11727] Fix | Delete
* @type {Array}
[11728] Fix | Delete
*/
[11729] Fix | Delete
const TEXT_NORMALIZATIONS = [identity, getTextWithCollapsedWhitespace];
[11730] Fix | Delete
[11731] Fix | Delete
/**
[11732] Fix | Delete
* Regular expression matching a named character reference. In lieu of bundling
[11733] Fix | Delete
* a full set of references, the pattern covers the minimal necessary to test
[11734] Fix | Delete
* positively against the full set.
[11735] Fix | Delete
*
[11736] Fix | Delete
* "The ampersand must be followed by one of the names given in the named
[11737] Fix | Delete
* character references section, using the same case."
[11738] Fix | Delete
*
[11739] Fix | Delete
* Tested aginst "12.5 Named character references":
[11740] Fix | Delete
*
[11741] Fix | Delete
* ```
[11742] Fix | Delete
* const references = Array.from( document.querySelectorAll(
[11743] Fix | Delete
* '#named-character-references-table tr[id^=entity-] td:first-child'
[11744] Fix | Delete
* ) ).map( ( code ) => code.textContent )
[11745] Fix | Delete
* references.every( ( reference ) => /^[\da-z]+$/i.test( reference ) )
[11746] Fix | Delete
* ```
[11747] Fix | Delete
*
[11748] Fix | Delete
* @see https://html.spec.whatwg.org/multipage/syntax.html#character-references
[11749] Fix | Delete
* @see https://html.spec.whatwg.org/multipage/named-characters.html#named-character-references
[11750] Fix | Delete
*
[11751] Fix | Delete
* @type {RegExp}
[11752] Fix | Delete
*/
[11753] Fix | Delete
const REGEXP_NAMED_CHARACTER_REFERENCE = /^[\da-z]+$/i;
[11754] Fix | Delete
[11755] Fix | Delete
/**
[11756] Fix | Delete
* Regular expression matching a decimal character reference.
[11757] Fix | Delete
*
[11758] Fix | Delete
* "The ampersand must be followed by a U+0023 NUMBER SIGN character (#),
[11759] Fix | Delete
* followed by one or more ASCII digits, representing a base-ten integer"
[11760] Fix | Delete
*
[11761] Fix | Delete
* @see https://html.spec.whatwg.org/multipage/syntax.html#character-references
[11762] Fix | Delete
*
[11763] Fix | Delete
* @type {RegExp}
[11764] Fix | Delete
*/
[11765] Fix | Delete
const REGEXP_DECIMAL_CHARACTER_REFERENCE = /^#\d+$/;
[11766] Fix | Delete
[11767] Fix | Delete
/**
[11768] Fix | Delete
* Regular expression matching a hexadecimal character reference.
[11769] Fix | Delete
*
[11770] Fix | Delete
* "The ampersand must be followed by a U+0023 NUMBER SIGN character (#), which
[11771] Fix | Delete
* must be followed by either a U+0078 LATIN SMALL LETTER X character (x) or a
[11772] Fix | Delete
* U+0058 LATIN CAPITAL LETTER X character (X), which must then be followed by
[11773] Fix | Delete
* one or more ASCII hex digits, representing a hexadecimal integer"
[11774] Fix | Delete
*
[11775] Fix | Delete
* @see https://html.spec.whatwg.org/multipage/syntax.html#character-references
[11776] Fix | Delete
*
[11777] Fix | Delete
* @type {RegExp}
[11778] Fix | Delete
*/
[11779] Fix | Delete
const REGEXP_HEXADECIMAL_CHARACTER_REFERENCE = /^#x[\da-f]+$/i;
[11780] Fix | Delete
[11781] Fix | Delete
/**
[11782] Fix | Delete
* Returns true if the given string is a valid character reference segment, or
[11783] Fix | Delete
* false otherwise. The text should be stripped of `&` and `;` demarcations.
[11784] Fix | Delete
*
[11785] Fix | Delete
* @param {string} text Text to test.
[11786] Fix | Delete
*
[11787] Fix | Delete
* @return {boolean} Whether text is valid character reference.
[11788] Fix | Delete
*/
[11789] Fix | Delete
function isValidCharacterReference(text) {
[11790] Fix | Delete
return REGEXP_NAMED_CHARACTER_REFERENCE.test(text) || REGEXP_DECIMAL_CHARACTER_REFERENCE.test(text) || REGEXP_HEXADECIMAL_CHARACTER_REFERENCE.test(text);
[11791] Fix | Delete
}
[11792] Fix | Delete
[11793] Fix | Delete
/**
[11794] Fix | Delete
* Subsitute EntityParser class for `simple-html-tokenizer` which uses the
[11795] Fix | Delete
* implementation of `decodeEntities` from `html-entities`, in order to avoid
[11796] Fix | Delete
* bundling a massive named character reference.
[11797] Fix | Delete
*
[11798] Fix | Delete
* @see https://github.com/tildeio/simple-html-tokenizer/tree/HEAD/src/entity-parser.ts
[11799] Fix | Delete
*/
[11800] Fix | Delete
class DecodeEntityParser {
[11801] Fix | Delete
/**
[11802] Fix | Delete
* Returns a substitute string for an entity string sequence between `&`
[11803] Fix | Delete
* and `;`, or undefined if no substitution should occur.
[11804] Fix | Delete
*
[11805] Fix | Delete
* @param {string} entity Entity fragment discovered in HTML.
[11806] Fix | Delete
*
[11807] Fix | Delete
* @return {string | undefined} Entity substitute value.
[11808] Fix | Delete
*/
[11809] Fix | Delete
parse(entity) {
[11810] Fix | Delete
if (isValidCharacterReference(entity)) {
[11811] Fix | Delete
return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)('&' + entity + ';');
[11812] Fix | Delete
}
[11813] Fix | Delete
}
[11814] Fix | Delete
}
[11815] Fix | Delete
[11816] Fix | Delete
/**
[11817] Fix | Delete
* Given a specified string, returns an array of strings split by consecutive
[11818] Fix | Delete
* whitespace, ignoring leading or trailing whitespace.
[11819] Fix | Delete
*
[11820] Fix | Delete
* @param {string} text Original text.
[11821] Fix | Delete
*
[11822] Fix | Delete
* @return {string[]} Text pieces split on whitespace.
[11823] Fix | Delete
*/
[11824] Fix | Delete
function getTextPiecesSplitOnWhitespace(text) {
[11825] Fix | Delete
return text.trim().split(REGEXP_WHITESPACE);
[11826] Fix | Delete
}
[11827] Fix | Delete
[11828] Fix | Delete
/**
[11829] Fix | Delete
* Given a specified string, returns a new trimmed string where all consecutive
[11830] Fix | Delete
* whitespace is collapsed to a single space.
[11831] Fix | Delete
*
[11832] Fix | Delete
* @param {string} text Original text.
[11833] Fix | Delete
*
[11834] Fix | Delete
* @return {string} Trimmed text with consecutive whitespace collapsed.
[11835] Fix | Delete
*/
[11836] Fix | Delete
function getTextWithCollapsedWhitespace(text) {
[11837] Fix | Delete
// This is an overly simplified whitespace comparison. The specification is
[11838] Fix | Delete
// more prescriptive of whitespace behavior in inline and block contexts.
[11839] Fix | Delete
//
[11840] Fix | Delete
// See: https://medium.com/@patrickbrosset/when-does-white-space-matter-in-html-b90e8a7cdd33
[11841] Fix | Delete
return getTextPiecesSplitOnWhitespace(text).join(' ');
[11842] Fix | Delete
}
[11843] Fix | Delete
[11844] Fix | Delete
/**
[11845] Fix | Delete
* Returns attribute pairs of the given StartTag token, including only pairs
[11846] Fix | Delete
* where the value is non-empty or the attribute is a boolean attribute, an
[11847] Fix | Delete
* enumerated attribute, or a custom data- attribute.
[11848] Fix | Delete
*
[11849] Fix | Delete
* @see MEANINGFUL_ATTRIBUTES
[11850] Fix | Delete
*
[11851] Fix | Delete
* @param {Object} token StartTag token.
[11852] Fix | Delete
*
[11853] Fix | Delete
* @return {Array[]} Attribute pairs.
[11854] Fix | Delete
*/
[11855] Fix | Delete
function getMeaningfulAttributePairs(token) {
[11856] Fix | Delete
return token.attributes.filter(pair => {
[11857] Fix | Delete
const [key, value] = pair;
[11858] Fix | Delete
return value || key.indexOf('data-') === 0 || MEANINGFUL_ATTRIBUTES.includes(key);
[11859] Fix | Delete
});
[11860] Fix | Delete
}
[11861] Fix | Delete
[11862] Fix | Delete
/**
[11863] Fix | Delete
* Returns true if two text tokens (with `chars` property) are equivalent, or
[11864] Fix | Delete
* false otherwise.
[11865] Fix | Delete
*
[11866] Fix | Delete
* @param {Object} actual Actual token.
[11867] Fix | Delete
* @param {Object} expected Expected token.
[11868] Fix | Delete
* @param {Object} logger Validation logger object.
[11869] Fix | Delete
*
[11870] Fix | Delete
* @return {boolean} Whether two text tokens are equivalent.
[11871] Fix | Delete
*/
[11872] Fix | Delete
function isEquivalentTextTokens(actual, expected, logger = createLogger()) {
[11873] Fix | Delete
// This function is intentionally written as syntactically "ugly" as a hot
[11874] Fix | Delete
// path optimization. Text is progressively normalized in order from least-
[11875] Fix | Delete
// to-most operationally expensive, until the earliest point at which text
[11876] Fix | Delete
// can be confidently inferred as being equal.
[11877] Fix | Delete
let actualChars = actual.chars;
[11878] Fix | Delete
let expectedChars = expected.chars;
[11879] Fix | Delete
for (let i = 0; i < TEXT_NORMALIZATIONS.length; i++) {
[11880] Fix | Delete
const normalize = TEXT_NORMALIZATIONS[i];
[11881] Fix | Delete
actualChars = normalize(actualChars);
[11882] Fix | Delete
expectedChars = normalize(expectedChars);
[11883] Fix | Delete
if (actualChars === expectedChars) {
[11884] Fix | Delete
return true;
[11885] Fix | Delete
}
[11886] Fix | Delete
}
[11887] Fix | Delete
logger.warning('Expected text `%s`, saw `%s`.', expected.chars, actual.chars);
[11888] Fix | Delete
return false;
[11889] Fix | Delete
}
[11890] Fix | Delete
[11891] Fix | Delete
/**
[11892] Fix | Delete
* Given a CSS length value, returns a normalized CSS length value for strict equality
[11893] Fix | Delete
* comparison.
[11894] Fix | Delete
*
[11895] Fix | Delete
* @param {string} value CSS length value.
[11896] Fix | Delete
*
[11897] Fix | Delete
* @return {string} Normalized CSS length value.
[11898] Fix | Delete
*/
[11899] Fix | Delete
function getNormalizedLength(value) {
[11900] Fix | Delete
if (0 === parseFloat(value)) {
[11901] Fix | Delete
return '0';
[11902] Fix | Delete
}
[11903] Fix | Delete
// Normalize strings with floats to always include a leading zero.
[11904] Fix | Delete
if (value.indexOf('.') === 0) {
[11905] Fix | Delete
return '0' + value;
[11906] Fix | Delete
}
[11907] Fix | Delete
return value;
[11908] Fix | Delete
}
[11909] Fix | Delete
[11910] Fix | Delete
/**
[11911] Fix | Delete
* Given a style value, returns a normalized style value for strict equality
[11912] Fix | Delete
* comparison.
[11913] Fix | Delete
*
[11914] Fix | Delete
* @param {string} value Style value.
[11915] Fix | Delete
*
[11916] Fix | Delete
* @return {string} Normalized style value.
[11917] Fix | Delete
*/
[11918] Fix | Delete
function getNormalizedStyleValue(value) {
[11919] Fix | Delete
const textPieces = getTextPiecesSplitOnWhitespace(value);
[11920] Fix | Delete
const normalizedPieces = textPieces.map(getNormalizedLength);
[11921] Fix | Delete
const result = normalizedPieces.join(' ');
[11922] Fix | Delete
return result
[11923] Fix | Delete
// Normalize URL type to omit whitespace or quotes.
[11924] Fix | Delete
.replace(REGEXP_STYLE_URL_TYPE, 'url($1)');
[11925] Fix | Delete
}
[11926] Fix | Delete
[11927] Fix | Delete
/**
[11928] Fix | Delete
* Given a style attribute string, returns an object of style properties.
[11929] Fix | Delete
*
[11930] Fix | Delete
* @param {string} text Style attribute.
[11931] Fix | Delete
*
[11932] Fix | Delete
* @return {Object} Style properties.
[11933] Fix | Delete
*/
[11934] Fix | Delete
function getStyleProperties(text) {
[11935] Fix | Delete
const pairs = text
[11936] Fix | Delete
// Trim ending semicolon (avoid including in split)
[11937] Fix | Delete
.replace(/;?\s*$/, '')
[11938] Fix | Delete
// Split on property assignment.
[11939] Fix | Delete
.split(';')
[11940] Fix | Delete
// For each property assignment...
[11941] Fix | Delete
.map(style => {
[11942] Fix | Delete
// ...split further into key-value pairs.
[11943] Fix | Delete
const [key, ...valueParts] = style.split(':');
[11944] Fix | Delete
const value = valueParts.join(':');
[11945] Fix | Delete
return [key.trim(), getNormalizedStyleValue(value.trim())];
[11946] Fix | Delete
});
[11947] Fix | Delete
return Object.fromEntries(pairs);
[11948] Fix | Delete
}
[11949] Fix | Delete
[11950] Fix | Delete
/**
[11951] Fix | Delete
* Attribute-specific equality handlers
[11952] Fix | Delete
*
[11953] Fix | Delete
* @type {Object}
[11954] Fix | Delete
*/
[11955] Fix | Delete
const isEqualAttributesOfName = {
[11956] Fix | Delete
class: (actual, expected) => {
[11957] Fix | Delete
// Class matches if members are the same, even if out of order or
[11958] Fix | Delete
// superfluous whitespace between.
[11959] Fix | Delete
const [actualPieces, expectedPieces] = [actual, expected].map(getTextPiecesSplitOnWhitespace);
[11960] Fix | Delete
const actualDiff = actualPieces.filter(c => !expectedPieces.includes(c));
[11961] Fix | Delete
const expectedDiff = expectedPieces.filter(c => !actualPieces.includes(c));
[11962] Fix | Delete
return actualDiff.length === 0 && expectedDiff.length === 0;
[11963] Fix | Delete
},
[11964] Fix | Delete
style: (actual, expected) => {
[11965] Fix | Delete
return es6_default()(...[actual, expected].map(getStyleProperties));
[11966] Fix | Delete
},
[11967] Fix | Delete
// For each boolean attribute, mere presence of attribute in both is enough
[11968] Fix | Delete
// to assume equivalence.
[11969] Fix | Delete
...Object.fromEntries(BOOLEAN_ATTRIBUTES.map(attribute => [attribute, () => true]))
[11970] Fix | Delete
};
[11971] Fix | Delete
[11972] Fix | Delete
/**
[11973] Fix | Delete
* Given two sets of attribute tuples, returns true if the attribute sets are
[11974] Fix | Delete
* equivalent.
[11975] Fix | Delete
*
[11976] Fix | Delete
* @param {Array[]} actual Actual attributes tuples.
[11977] Fix | Delete
* @param {Array[]} expected Expected attributes tuples.
[11978] Fix | Delete
* @param {Object} logger Validation logger object.
[11979] Fix | Delete
*
[11980] Fix | Delete
* @return {boolean} Whether attributes are equivalent.
[11981] Fix | Delete
*/
[11982] Fix | Delete
function isEqualTagAttributePairs(actual, expected, logger = createLogger()) {
[11983] Fix | Delete
// Attributes is tokenized as tuples. Their lengths should match. This also
[11984] Fix | Delete
// avoids us needing to check both attributes sets, since if A has any keys
[11985] Fix | Delete
// which do not exist in B, we know the sets to be different.
[11986] Fix | Delete
if (actual.length !== expected.length) {
[11987] Fix | Delete
logger.warning('Expected attributes %o, instead saw %o.', expected, actual);
[11988] Fix | Delete
return false;
[11989] Fix | Delete
}
[11990] Fix | Delete
[11991] Fix | Delete
// Attributes are not guaranteed to occur in the same order. For validating
[11992] Fix | Delete
// actual attributes, first convert the set of expected attribute values to
[11993] Fix | Delete
// an object, for lookup by key.
[11994] Fix | Delete
const expectedAttributes = {};
[11995] Fix | Delete
for (let i = 0; i < expected.length; i++) {
[11996] Fix | Delete
expectedAttributes[expected[i][0].toLowerCase()] = expected[i][1];
[11997] Fix | Delete
}
[11998] Fix | Delete
for (let i = 0; i < actual.length; i++) {
[11999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function