Edit File by line
/home/barbar84/www/wp-inclu.../js/dist
File: blocks.js
function __experimentalCloneSanitizedBlock(block) {
[2000] Fix | Delete
var mergeAttributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
[2001] Fix | Delete
var newInnerBlocks = arguments.length > 2 ? arguments[2] : undefined;
[2002] Fix | Delete
var clientId = Object(v4["a" /* default */])();
[2003] Fix | Delete
var sanitizedAttributes = sanitizeBlockAttributes(block.name, factory_objectSpread(factory_objectSpread({}, block.attributes), mergeAttributes));
[2004] Fix | Delete
return factory_objectSpread(factory_objectSpread({}, block), {}, {
[2005] Fix | Delete
clientId: clientId,
[2006] Fix | Delete
attributes: sanitizedAttributes,
[2007] Fix | Delete
innerBlocks: newInnerBlocks || block.innerBlocks.map(function (innerBlock) {
[2008] Fix | Delete
return __experimentalCloneSanitizedBlock(innerBlock);
[2009] Fix | Delete
})
[2010] Fix | Delete
});
[2011] Fix | Delete
}
[2012] Fix | Delete
/**
[2013] Fix | Delete
* Given a block object, returns a copy of the block object,
[2014] Fix | Delete
* optionally merging new attributes and/or replacing its inner blocks.
[2015] Fix | Delete
*
[2016] Fix | Delete
* @param {Object} block Block instance.
[2017] Fix | Delete
* @param {Object} mergeAttributes Block attributes.
[2018] Fix | Delete
* @param {?Array} newInnerBlocks Nested blocks.
[2019] Fix | Delete
*
[2020] Fix | Delete
* @return {Object} A cloned block.
[2021] Fix | Delete
*/
[2022] Fix | Delete
[2023] Fix | Delete
function cloneBlock(block) {
[2024] Fix | Delete
var mergeAttributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
[2025] Fix | Delete
var newInnerBlocks = arguments.length > 2 ? arguments[2] : undefined;
[2026] Fix | Delete
var clientId = Object(v4["a" /* default */])();
[2027] Fix | Delete
return factory_objectSpread(factory_objectSpread({}, block), {}, {
[2028] Fix | Delete
clientId: clientId,
[2029] Fix | Delete
attributes: factory_objectSpread(factory_objectSpread({}, block.attributes), mergeAttributes),
[2030] Fix | Delete
innerBlocks: newInnerBlocks || block.innerBlocks.map(function (innerBlock) {
[2031] Fix | Delete
return cloneBlock(innerBlock);
[2032] Fix | Delete
})
[2033] Fix | Delete
});
[2034] Fix | Delete
}
[2035] Fix | Delete
/**
[2036] Fix | Delete
* Returns a boolean indicating whether a transform is possible based on
[2037] Fix | Delete
* various bits of context.
[2038] Fix | Delete
*
[2039] Fix | Delete
* @param {Object} transform The transform object to validate.
[2040] Fix | Delete
* @param {string} direction Is this a 'from' or 'to' transform.
[2041] Fix | Delete
* @param {Array} blocks The blocks to transform from.
[2042] Fix | Delete
*
[2043] Fix | Delete
* @return {boolean} Is the transform possible?
[2044] Fix | Delete
*/
[2045] Fix | Delete
[2046] Fix | Delete
var factory_isPossibleTransformForSource = function isPossibleTransformForSource(transform, direction, blocks) {
[2047] Fix | Delete
if (Object(external_lodash_["isEmpty"])(blocks)) {
[2048] Fix | Delete
return false;
[2049] Fix | Delete
} // If multiple blocks are selected, only multi block transforms
[2050] Fix | Delete
// or wildcard transforms are allowed.
[2051] Fix | Delete
[2052] Fix | Delete
[2053] Fix | Delete
var isMultiBlock = blocks.length > 1;
[2054] Fix | Delete
var firstBlockName = Object(external_lodash_["first"])(blocks).name;
[2055] Fix | Delete
var isValidForMultiBlocks = isWildcardBlockTransform(transform) || !isMultiBlock || transform.isMultiBlock;
[2056] Fix | Delete
[2057] Fix | Delete
if (!isValidForMultiBlocks) {
[2058] Fix | Delete
return false;
[2059] Fix | Delete
} // Check non-wildcard transforms to ensure that transform is valid
[2060] Fix | Delete
// for a block selection of multiple blocks of different types
[2061] Fix | Delete
[2062] Fix | Delete
[2063] Fix | Delete
if (!isWildcardBlockTransform(transform) && !Object(external_lodash_["every"])(blocks, {
[2064] Fix | Delete
name: firstBlockName
[2065] Fix | Delete
})) {
[2066] Fix | Delete
return false;
[2067] Fix | Delete
} // Only consider 'block' type transforms as valid.
[2068] Fix | Delete
[2069] Fix | Delete
[2070] Fix | Delete
var isBlockType = transform.type === 'block';
[2071] Fix | Delete
[2072] Fix | Delete
if (!isBlockType) {
[2073] Fix | Delete
return false;
[2074] Fix | Delete
} // Check if the transform's block name matches the source block (or is a wildcard)
[2075] Fix | Delete
// only if this is a transform 'from'.
[2076] Fix | Delete
[2077] Fix | Delete
[2078] Fix | Delete
var sourceBlock = Object(external_lodash_["first"])(blocks);
[2079] Fix | Delete
var hasMatchingName = direction !== 'from' || transform.blocks.indexOf(sourceBlock.name) !== -1 || isWildcardBlockTransform(transform);
[2080] Fix | Delete
[2081] Fix | Delete
if (!hasMatchingName) {
[2082] Fix | Delete
return false;
[2083] Fix | Delete
} // Don't allow single Grouping blocks to be transformed into
[2084] Fix | Delete
// a Grouping block.
[2085] Fix | Delete
[2086] Fix | Delete
[2087] Fix | Delete
if (!isMultiBlock && factory_isContainerGroupBlock(sourceBlock.name) && factory_isContainerGroupBlock(transform.blockName)) {
[2088] Fix | Delete
return false;
[2089] Fix | Delete
} // If the transform has a `isMatch` function specified, check that it returns true.
[2090] Fix | Delete
[2091] Fix | Delete
[2092] Fix | Delete
if (Object(external_lodash_["isFunction"])(transform.isMatch)) {
[2093] Fix | Delete
var attributes = transform.isMultiBlock ? blocks.map(function (block) {
[2094] Fix | Delete
return block.attributes;
[2095] Fix | Delete
}) : sourceBlock.attributes;
[2096] Fix | Delete
[2097] Fix | Delete
if (!transform.isMatch(attributes)) {
[2098] Fix | Delete
return false;
[2099] Fix | Delete
}
[2100] Fix | Delete
}
[2101] Fix | Delete
[2102] Fix | Delete
return true;
[2103] Fix | Delete
};
[2104] Fix | Delete
/**
[2105] Fix | Delete
* Returns block types that the 'blocks' can be transformed into, based on
[2106] Fix | Delete
* 'from' transforms on other blocks.
[2107] Fix | Delete
*
[2108] Fix | Delete
* @param {Array} blocks The blocks to transform from.
[2109] Fix | Delete
*
[2110] Fix | Delete
* @return {Array} Block types that the blocks can be transformed into.
[2111] Fix | Delete
*/
[2112] Fix | Delete
[2113] Fix | Delete
[2114] Fix | Delete
var factory_getBlockTypesForPossibleFromTransforms = function getBlockTypesForPossibleFromTransforms(blocks) {
[2115] Fix | Delete
if (Object(external_lodash_["isEmpty"])(blocks)) {
[2116] Fix | Delete
return [];
[2117] Fix | Delete
}
[2118] Fix | Delete
[2119] Fix | Delete
var allBlockTypes = registration_getBlockTypes(); // filter all blocks to find those with a 'from' transform.
[2120] Fix | Delete
[2121] Fix | Delete
var blockTypesWithPossibleFromTransforms = Object(external_lodash_["filter"])(allBlockTypes, function (blockType) {
[2122] Fix | Delete
var fromTransforms = getBlockTransforms('from', blockType.name);
[2123] Fix | Delete
return !!findTransform(fromTransforms, function (transform) {
[2124] Fix | Delete
return factory_isPossibleTransformForSource(transform, 'from', blocks);
[2125] Fix | Delete
});
[2126] Fix | Delete
});
[2127] Fix | Delete
return blockTypesWithPossibleFromTransforms;
[2128] Fix | Delete
};
[2129] Fix | Delete
/**
[2130] Fix | Delete
* Returns block types that the 'blocks' can be transformed into, based on
[2131] Fix | Delete
* the source block's own 'to' transforms.
[2132] Fix | Delete
*
[2133] Fix | Delete
* @param {Array} blocks The blocks to transform from.
[2134] Fix | Delete
*
[2135] Fix | Delete
* @return {Array} Block types that the source can be transformed into.
[2136] Fix | Delete
*/
[2137] Fix | Delete
[2138] Fix | Delete
[2139] Fix | Delete
var factory_getBlockTypesForPossibleToTransforms = function getBlockTypesForPossibleToTransforms(blocks) {
[2140] Fix | Delete
if (Object(external_lodash_["isEmpty"])(blocks)) {
[2141] Fix | Delete
return [];
[2142] Fix | Delete
}
[2143] Fix | Delete
[2144] Fix | Delete
var sourceBlock = Object(external_lodash_["first"])(blocks);
[2145] Fix | Delete
var blockType = registration_getBlockType(sourceBlock.name);
[2146] Fix | Delete
var transformsTo = getBlockTransforms('to', blockType.name); // filter all 'to' transforms to find those that are possible.
[2147] Fix | Delete
[2148] Fix | Delete
var possibleTransforms = Object(external_lodash_["filter"])(transformsTo, function (transform) {
[2149] Fix | Delete
return transform && factory_isPossibleTransformForSource(transform, 'to', blocks);
[2150] Fix | Delete
}); // Build a list of block names using the possible 'to' transforms.
[2151] Fix | Delete
[2152] Fix | Delete
var blockNames = Object(external_lodash_["flatMap"])(possibleTransforms, function (transformation) {
[2153] Fix | Delete
return transformation.blocks;
[2154] Fix | Delete
}); // Map block names to block types.
[2155] Fix | Delete
[2156] Fix | Delete
return blockNames.map(function (name) {
[2157] Fix | Delete
return registration_getBlockType(name);
[2158] Fix | Delete
});
[2159] Fix | Delete
};
[2160] Fix | Delete
/**
[2161] Fix | Delete
* Determines whether transform is a "block" type
[2162] Fix | Delete
* and if so whether it is a "wildcard" transform
[2163] Fix | Delete
* ie: targets "any" block type
[2164] Fix | Delete
*
[2165] Fix | Delete
* @param {Object} t the Block transform object
[2166] Fix | Delete
*
[2167] Fix | Delete
* @return {boolean} whether transform is a wildcard transform
[2168] Fix | Delete
*/
[2169] Fix | Delete
[2170] Fix | Delete
[2171] Fix | Delete
var isWildcardBlockTransform = function isWildcardBlockTransform(t) {
[2172] Fix | Delete
return t && t.type === 'block' && Array.isArray(t.blocks) && t.blocks.includes('*');
[2173] Fix | Delete
};
[2174] Fix | Delete
/**
[2175] Fix | Delete
* Determines whether the given Block is the core Block which
[2176] Fix | Delete
* acts as a container Block for other Blocks as part of the
[2177] Fix | Delete
* Grouping mechanics
[2178] Fix | Delete
*
[2179] Fix | Delete
* @param {string} name the name of the Block to test against
[2180] Fix | Delete
*
[2181] Fix | Delete
* @return {boolean} whether or not the Block is the container Block type
[2182] Fix | Delete
*/
[2183] Fix | Delete
[2184] Fix | Delete
var factory_isContainerGroupBlock = function isContainerGroupBlock(name) {
[2185] Fix | Delete
return name === registration_getGroupingBlockName();
[2186] Fix | Delete
};
[2187] Fix | Delete
/**
[2188] Fix | Delete
* Returns an array of block types that the set of blocks received as argument
[2189] Fix | Delete
* can be transformed into.
[2190] Fix | Delete
*
[2191] Fix | Delete
* @param {Array} blocks Blocks array.
[2192] Fix | Delete
*
[2193] Fix | Delete
* @return {Array} Block types that the blocks argument can be transformed to.
[2194] Fix | Delete
*/
[2195] Fix | Delete
[2196] Fix | Delete
function getPossibleBlockTransformations(blocks) {
[2197] Fix | Delete
if (Object(external_lodash_["isEmpty"])(blocks)) {
[2198] Fix | Delete
return [];
[2199] Fix | Delete
}
[2200] Fix | Delete
[2201] Fix | Delete
var blockTypesForFromTransforms = factory_getBlockTypesForPossibleFromTransforms(blocks);
[2202] Fix | Delete
var blockTypesForToTransforms = factory_getBlockTypesForPossibleToTransforms(blocks);
[2203] Fix | Delete
return Object(external_lodash_["uniq"])([].concat(Object(toConsumableArray["a" /* default */])(blockTypesForFromTransforms), Object(toConsumableArray["a" /* default */])(blockTypesForToTransforms)));
[2204] Fix | Delete
}
[2205] Fix | Delete
/**
[2206] Fix | Delete
* Given an array of transforms, returns the highest-priority transform where
[2207] Fix | Delete
* the predicate function returns a truthy value. A higher-priority transform
[2208] Fix | Delete
* is one with a lower priority value (i.e. first in priority order). Returns
[2209] Fix | Delete
* null if the transforms set is empty or the predicate function returns a
[2210] Fix | Delete
* falsey value for all entries.
[2211] Fix | Delete
*
[2212] Fix | Delete
* @param {Object[]} transforms Transforms to search.
[2213] Fix | Delete
* @param {Function} predicate Function returning true on matching transform.
[2214] Fix | Delete
*
[2215] Fix | Delete
* @return {?Object} Highest-priority transform candidate.
[2216] Fix | Delete
*/
[2217] Fix | Delete
[2218] Fix | Delete
function findTransform(transforms, predicate) {
[2219] Fix | Delete
// The hooks library already has built-in mechanisms for managing priority
[2220] Fix | Delete
// queue, so leverage via locally-defined instance.
[2221] Fix | Delete
var hooks = Object(external_wp_hooks_["createHooks"])();
[2222] Fix | Delete
[2223] Fix | Delete
var _loop = function _loop(i) {
[2224] Fix | Delete
var candidate = transforms[i];
[2225] Fix | Delete
[2226] Fix | Delete
if (predicate(candidate)) {
[2227] Fix | Delete
hooks.addFilter('transform', 'transform/' + i.toString(), function (result) {
[2228] Fix | Delete
return result ? result : candidate;
[2229] Fix | Delete
}, candidate.priority);
[2230] Fix | Delete
}
[2231] Fix | Delete
};
[2232] Fix | Delete
[2233] Fix | Delete
for (var i = 0; i < transforms.length; i++) {
[2234] Fix | Delete
_loop(i);
[2235] Fix | Delete
} // Filter name is arbitrarily chosen but consistent with above aggregation.
[2236] Fix | Delete
[2237] Fix | Delete
[2238] Fix | Delete
return hooks.applyFilters('transform', null);
[2239] Fix | Delete
}
[2240] Fix | Delete
/**
[2241] Fix | Delete
* Returns normal block transforms for a given transform direction, optionally
[2242] Fix | Delete
* for a specific block by name, or an empty array if there are no transforms.
[2243] Fix | Delete
* If no block name is provided, returns transforms for all blocks. A normal
[2244] Fix | Delete
* transform object includes `blockName` as a property.
[2245] Fix | Delete
*
[2246] Fix | Delete
* @param {string} direction Transform direction ("to", "from").
[2247] Fix | Delete
* @param {string|Object} blockTypeOrName Block type or name.
[2248] Fix | Delete
*
[2249] Fix | Delete
* @return {Array} Block transforms for direction.
[2250] Fix | Delete
*/
[2251] Fix | Delete
[2252] Fix | Delete
function getBlockTransforms(direction, blockTypeOrName) {
[2253] Fix | Delete
// When retrieving transforms for all block types, recurse into self.
[2254] Fix | Delete
if (blockTypeOrName === undefined) {
[2255] Fix | Delete
return Object(external_lodash_["flatMap"])(registration_getBlockTypes(), function (_ref) {
[2256] Fix | Delete
var name = _ref.name;
[2257] Fix | Delete
return getBlockTransforms(direction, name);
[2258] Fix | Delete
});
[2259] Fix | Delete
} // Validate that block type exists and has array of direction.
[2260] Fix | Delete
[2261] Fix | Delete
[2262] Fix | Delete
var blockType = normalizeBlockType(blockTypeOrName);
[2263] Fix | Delete
[2264] Fix | Delete
var _ref2 = blockType || {},
[2265] Fix | Delete
blockName = _ref2.name,
[2266] Fix | Delete
transforms = _ref2.transforms;
[2267] Fix | Delete
[2268] Fix | Delete
if (!transforms || !Array.isArray(transforms[direction])) {
[2269] Fix | Delete
return [];
[2270] Fix | Delete
} // Map transforms to normal form.
[2271] Fix | Delete
[2272] Fix | Delete
[2273] Fix | Delete
return transforms[direction].map(function (transform) {
[2274] Fix | Delete
return factory_objectSpread(factory_objectSpread({}, transform), {}, {
[2275] Fix | Delete
blockName: blockName
[2276] Fix | Delete
});
[2277] Fix | Delete
});
[2278] Fix | Delete
}
[2279] Fix | Delete
/**
[2280] Fix | Delete
* Switch one or more blocks into one or more blocks of the new block type.
[2281] Fix | Delete
*
[2282] Fix | Delete
* @param {Array|Object} blocks Blocks array or block object.
[2283] Fix | Delete
* @param {string} name Block name.
[2284] Fix | Delete
*
[2285] Fix | Delete
* @return {?Array} Array of blocks or null.
[2286] Fix | Delete
*/
[2287] Fix | Delete
[2288] Fix | Delete
function switchToBlockType(blocks, name) {
[2289] Fix | Delete
var blocksArray = Object(external_lodash_["castArray"])(blocks);
[2290] Fix | Delete
var isMultiBlock = blocksArray.length > 1;
[2291] Fix | Delete
var firstBlock = blocksArray[0];
[2292] Fix | Delete
var sourceName = firstBlock.name; // Find the right transformation by giving priority to the "to"
[2293] Fix | Delete
// transformation.
[2294] Fix | Delete
[2295] Fix | Delete
var transformationsFrom = getBlockTransforms('from', name);
[2296] Fix | Delete
var transformationsTo = getBlockTransforms('to', sourceName);
[2297] Fix | Delete
var transformation = findTransform(transformationsTo, function (t) {
[2298] Fix | Delete
return t.type === 'block' && (isWildcardBlockTransform(t) || t.blocks.indexOf(name) !== -1) && (!isMultiBlock || t.isMultiBlock);
[2299] Fix | Delete
}) || findTransform(transformationsFrom, function (t) {
[2300] Fix | Delete
return t.type === 'block' && (isWildcardBlockTransform(t) || t.blocks.indexOf(sourceName) !== -1) && (!isMultiBlock || t.isMultiBlock);
[2301] Fix | Delete
}); // Stop if there is no valid transformation.
[2302] Fix | Delete
[2303] Fix | Delete
if (!transformation) {
[2304] Fix | Delete
return null;
[2305] Fix | Delete
}
[2306] Fix | Delete
[2307] Fix | Delete
var transformationResults;
[2308] Fix | Delete
[2309] Fix | Delete
if (transformation.isMultiBlock) {
[2310] Fix | Delete
if (Object(external_lodash_["has"])(transformation, '__experimentalConvert')) {
[2311] Fix | Delete
transformationResults = transformation.__experimentalConvert(blocksArray);
[2312] Fix | Delete
} else {
[2313] Fix | Delete
transformationResults = transformation.transform(blocksArray.map(function (currentBlock) {
[2314] Fix | Delete
return currentBlock.attributes;
[2315] Fix | Delete
}), blocksArray.map(function (currentBlock) {
[2316] Fix | Delete
return currentBlock.innerBlocks;
[2317] Fix | Delete
}));
[2318] Fix | Delete
}
[2319] Fix | Delete
} else if (Object(external_lodash_["has"])(transformation, '__experimentalConvert')) {
[2320] Fix | Delete
transformationResults = transformation.__experimentalConvert(firstBlock);
[2321] Fix | Delete
} else {
[2322] Fix | Delete
transformationResults = transformation.transform(firstBlock.attributes, firstBlock.innerBlocks);
[2323] Fix | Delete
} // Ensure that the transformation function returned an object or an array
[2324] Fix | Delete
// of objects.
[2325] Fix | Delete
[2326] Fix | Delete
[2327] Fix | Delete
if (!Object(external_lodash_["isObjectLike"])(transformationResults)) {
[2328] Fix | Delete
return null;
[2329] Fix | Delete
} // If the transformation function returned a single object, we want to work
[2330] Fix | Delete
// with an array instead.
[2331] Fix | Delete
[2332] Fix | Delete
[2333] Fix | Delete
transformationResults = Object(external_lodash_["castArray"])(transformationResults); // Ensure that every block object returned by the transformation has a
[2334] Fix | Delete
// valid block type.
[2335] Fix | Delete
[2336] Fix | Delete
if (transformationResults.some(function (result) {
[2337] Fix | Delete
return !registration_getBlockType(result.name);
[2338] Fix | Delete
})) {
[2339] Fix | Delete
return null;
[2340] Fix | Delete
}
[2341] Fix | Delete
[2342] Fix | Delete
var firstSwitchedBlock = Object(external_lodash_["findIndex"])(transformationResults, function (result) {
[2343] Fix | Delete
return result.name === name;
[2344] Fix | Delete
}); // Ensure that at least one block object returned by the transformation has
[2345] Fix | Delete
// the expected "destination" block type.
[2346] Fix | Delete
[2347] Fix | Delete
if (firstSwitchedBlock < 0) {
[2348] Fix | Delete
return null;
[2349] Fix | Delete
}
[2350] Fix | Delete
[2351] Fix | Delete
return transformationResults.map(function (result, index) {
[2352] Fix | Delete
var transformedBlock = factory_objectSpread(factory_objectSpread({}, result), {}, {
[2353] Fix | Delete
// The first transformed block whose type matches the "destination"
[2354] Fix | Delete
// type gets to keep the existing client ID of the first block.
[2355] Fix | Delete
clientId: index === firstSwitchedBlock ? firstBlock.clientId : result.clientId
[2356] Fix | Delete
});
[2357] Fix | Delete
/**
[2358] Fix | Delete
* Filters an individual transform result from block transformation.
[2359] Fix | Delete
* All of the original blocks are passed, since transformations are
[2360] Fix | Delete
* many-to-many, not one-to-one.
[2361] Fix | Delete
*
[2362] Fix | Delete
* @param {Object} transformedBlock The transformed block.
[2363] Fix | Delete
* @param {Object[]} blocks Original blocks transformed.
[2364] Fix | Delete
*/
[2365] Fix | Delete
[2366] Fix | Delete
[2367] Fix | Delete
return Object(external_wp_hooks_["applyFilters"])('blocks.switchToBlockType.transformedBlock', transformedBlock, blocks);
[2368] Fix | Delete
});
[2369] Fix | Delete
}
[2370] Fix | Delete
/**
[2371] Fix | Delete
* Create a block object from the example API.
[2372] Fix | Delete
*
[2373] Fix | Delete
* @param {string} name
[2374] Fix | Delete
* @param {Object} example
[2375] Fix | Delete
*
[2376] Fix | Delete
* @return {Object} block.
[2377] Fix | Delete
*/
[2378] Fix | Delete
[2379] Fix | Delete
var factory_getBlockFromExample = function getBlockFromExample(name, example) {
[2380] Fix | Delete
return createBlock(name, example.attributes, Object(external_lodash_["map"])(example.innerBlocks, function (innerBlock) {
[2381] Fix | Delete
return getBlockFromExample(innerBlock.name, innerBlock);
[2382] Fix | Delete
}));
[2383] Fix | Delete
};
[2384] Fix | Delete
[2385] Fix | Delete
// CONCATENATED MODULE: ./node_modules/hpq/es/get-path.js
[2386] Fix | Delete
/**
[2387] Fix | Delete
* Given object and string of dot-delimited path segments, returns value at
[2388] Fix | Delete
* path or undefined if path cannot be resolved.
[2389] Fix | Delete
*
[2390] Fix | Delete
* @param {Object} object Lookup object
[2391] Fix | Delete
* @param {string} path Path to resolve
[2392] Fix | Delete
* @return {?*} Resolved value
[2393] Fix | Delete
*/
[2394] Fix | Delete
function getPath(object, path) {
[2395] Fix | Delete
var segments = path.split('.');
[2396] Fix | Delete
var segment;
[2397] Fix | Delete
[2398] Fix | Delete
while (segment = segments.shift()) {
[2399] Fix | Delete
if (!(segment in object)) {
[2400] Fix | Delete
return;
[2401] Fix | Delete
}
[2402] Fix | Delete
[2403] Fix | Delete
object = object[segment];
[2404] Fix | Delete
}
[2405] Fix | Delete
[2406] Fix | Delete
return object;
[2407] Fix | Delete
}
[2408] Fix | Delete
// CONCATENATED MODULE: ./node_modules/hpq/es/index.js
[2409] Fix | Delete
/**
[2410] Fix | Delete
* Internal dependencies
[2411] Fix | Delete
*/
[2412] Fix | Delete
[2413] Fix | Delete
/**
[2414] Fix | Delete
* Function returning a DOM document created by `createHTMLDocument`. The same
[2415] Fix | Delete
* document is returned between invocations.
[2416] Fix | Delete
*
[2417] Fix | Delete
* @return {Document} DOM document.
[2418] Fix | Delete
*/
[2419] Fix | Delete
[2420] Fix | Delete
var getDocument = function () {
[2421] Fix | Delete
var doc;
[2422] Fix | Delete
return function () {
[2423] Fix | Delete
if (!doc) {
[2424] Fix | Delete
doc = document.implementation.createHTMLDocument('');
[2425] Fix | Delete
}
[2426] Fix | Delete
[2427] Fix | Delete
return doc;
[2428] Fix | Delete
};
[2429] Fix | Delete
}();
[2430] Fix | Delete
/**
[2431] Fix | Delete
* Given a markup string or DOM element, creates an object aligning with the
[2432] Fix | Delete
* shape of the matchers object, or the value returned by the matcher.
[2433] Fix | Delete
*
[2434] Fix | Delete
* @param {(string|Element)} source Source content
[2435] Fix | Delete
* @param {(Object|Function)} matchers Matcher function or object of matchers
[2436] Fix | Delete
* @return {(Object|*)} Matched value(s), shaped by object
[2437] Fix | Delete
*/
[2438] Fix | Delete
[2439] Fix | Delete
[2440] Fix | Delete
function es_parse(source, matchers) {
[2441] Fix | Delete
if (!matchers) {
[2442] Fix | Delete
return;
[2443] Fix | Delete
} // Coerce to element
[2444] Fix | Delete
[2445] Fix | Delete
[2446] Fix | Delete
if ('string' === typeof source) {
[2447] Fix | Delete
var doc = getDocument();
[2448] Fix | Delete
doc.body.innerHTML = source;
[2449] Fix | Delete
source = doc.body;
[2450] Fix | Delete
} // Return singular value
[2451] Fix | Delete
[2452] Fix | Delete
[2453] Fix | Delete
if ('function' === typeof matchers) {
[2454] Fix | Delete
return matchers(source);
[2455] Fix | Delete
} // Bail if we can't handle matchers
[2456] Fix | Delete
[2457] Fix | Delete
[2458] Fix | Delete
if (Object !== matchers.constructor) {
[2459] Fix | Delete
return;
[2460] Fix | Delete
} // Shape result by matcher object
[2461] Fix | Delete
[2462] Fix | Delete
[2463] Fix | Delete
return Object.keys(matchers).reduce(function (memo, key) {
[2464] Fix | Delete
memo[key] = es_parse(source, matchers[key]);
[2465] Fix | Delete
return memo;
[2466] Fix | Delete
}, {});
[2467] Fix | Delete
}
[2468] Fix | Delete
/**
[2469] Fix | Delete
* Generates a function which matches node of type selector, returning an
[2470] Fix | Delete
* attribute by property if the attribute exists. If no selector is passed,
[2471] Fix | Delete
* returns property of the query element.
[2472] Fix | Delete
*
[2473] Fix | Delete
* @param {?string} selector Optional selector
[2474] Fix | Delete
* @param {string} name Property name
[2475] Fix | Delete
* @return {*} Property value
[2476] Fix | Delete
*/
[2477] Fix | Delete
[2478] Fix | Delete
function prop(selector, name) {
[2479] Fix | Delete
if (1 === arguments.length) {
[2480] Fix | Delete
name = selector;
[2481] Fix | Delete
selector = undefined;
[2482] Fix | Delete
}
[2483] Fix | Delete
[2484] Fix | Delete
return function (node) {
[2485] Fix | Delete
var match = node;
[2486] Fix | Delete
[2487] Fix | Delete
if (selector) {
[2488] Fix | Delete
match = node.querySelector(selector);
[2489] Fix | Delete
}
[2490] Fix | Delete
[2491] Fix | Delete
if (match) {
[2492] Fix | Delete
return getPath(match, name);
[2493] Fix | Delete
}
[2494] Fix | Delete
};
[2495] Fix | Delete
}
[2496] Fix | Delete
/**
[2497] Fix | Delete
* Generates a function which matches node of type selector, returning an
[2498] Fix | Delete
* attribute by name if the attribute exists. If no selector is passed,
[2499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function