1import { render } from "../../react-dom.js"; 2 3function renderChildren(children, container) { 4 if (Array.isArray(children)) { 5 return children.forEach((child) => render(child, container)); 6 } 7 return render(children, container); 8} 9 10function setEvents(element, event, callback) { 11 return element.addEventListener(event, callback); 12} 13 14function setProperties(prop, value, element) { 15 // events support 16 if (prop.startsWith("on")) { 17 const event = prop.replace("on", "").toLowerCase(); 18 return setEvents(element, event, value); 19 } 20 21 // support for children 22 if (prop === "children") { 23 return renderChildren(value, element); 24 } 25 26 // support for attributes 27 const attribute = value; 28 return element.setAttribute(prop, attribute); 29} 30 31export function createElement(type, props, content) { 32 const element = document.createElement(type); 33 34 // Content 35 if (content) { 36 element.textContent = content; 37 } 38 // Propiedades 39 if (props) { 40 Object.keys(props).forEach((prop) => 41 setProperties(prop, props[prop], element) 42 ); 43 } 44 45 return element; 46}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.