in packages/eui/scripts/jest/polyfills/mutation_observer.js [54:93]
Util.clone = function ($target, config) {
var recurse = true; // set true so childList we'll always check the first level
return (function copy($target) {
var elestruct = {
/** @type {Node} */
node: $target,
charData: null,
attr: null,
kids: null,
};
// Store current character data of target text or comment node if the config requests
// those properties to be observed.
if (config.charData && ($target.nodeType === 3 || $target.nodeType === 8)) {
elestruct.charData = $target.nodeValue;
}
else {
// Add attr only if subtree is specified or top level and avoid if
// attributes is a document object (#13).
if (config.attr && recurse && $target.nodeType === 1) {
/**
* clone live attribute list to an object structure {name: val}
* @type {Object.<string, string>}
*/
elestruct.attr = Util.reduce($target.attributes, function (memo, attr) {
if (!config.afilter || config.afilter[attr.name]) {
memo[attr.name] = attr.value;
}
return memo;
}, {});
}
// whether we should iterate the children of $target node
if (recurse && ((config.kids || config.charData) || (config.attr && config.descendents))) {
/** @type {Array.<!Object>} : Array of custom clone */
elestruct.kids = Util.map($target.childNodes, copy);
}
recurse = config.descendents;
}
return elestruct;
})($target);
};