@jay-js/system
Version:
A powerful and flexible TypeScript library for UI, state management, lazy loading, routing and managing draggable elements in modern web applications.
37 lines • 1.3 kB
JavaScript
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
export function Fragment(_a) {
var { children } = _a, props = __rest(_a, ["children"]);
const fragment = document.createDocumentFragment();
props &&
Object.entries(props).forEach(([key, value]) => {
try {
fragment[key] = value;
}
catch (error) {
if (error instanceof TypeError) {
console.warn(`JayJS: Cannot set property '${key}' of type '${typeof value}' to '${value}'.`);
throw error;
}
}
});
if (Array.isArray(children)) {
children.forEach((item) => {
fragment.append(item);
});
}
else {
children && fragment.append(children);
}
return fragment;
}
//# sourceMappingURL=fragment.js.map