UNPKG

syphonx-core

Version:

SyphonX is a template-driven solution for extracting data from HTML in a highly efficient way. It combines the power of jQuery, Regular Expressions, and Javascript into a declarative template-driven format that extracts and reshapes HTML data into JSON.

30 lines 1.31 kB
"use strict"; var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.mergeElements = void 0; function mergeElements(source, target) { var _loop_1 = function (targetAttr) { var sourceAttr = Array.from(source[0].attributes).find(function (attr) { return attr.name === targetAttr.name; }); if (sourceAttr && targetAttr.name === "class") { var value = Array.from(new Set(__spreadArray(__spreadArray([], sourceAttr.value.split(" "), true), targetAttr.value.split(" "), true))).join(" "); source.attr("class", value); } else if (!sourceAttr) { source.attr(targetAttr.name, targetAttr.value); } }; for (var _i = 0, _a = Array.from(target[0].attributes); _i < _a.length; _i++) { var targetAttr = _a[_i]; _loop_1(targetAttr); } } exports.mergeElements = mergeElements; //# sourceMappingURL=mergeElements.js.map