This function prepends content to an element. It works exactly the same as ParentNode.prepend()
except that when the implied content is undefined, it is converted to an empty string.
The suffix Sync differentiates this method from its Async counterpart - prependAsync()
. Unlike the Async counterpart, prependSync()
is a normal function that runs in the same flow with that of the calling code.
import prependSync from '@web-native-js/play-ui/src/dom/prependSync.js';
prependSync(el[, ...content);
el
-HTMLElement
: The target DOM element.content
-[String|HTMLElement]
: The set of content to prepend. Each could be a plain text, an HTML/XML markup, or even a DOM node.
HTMLElement
- The target DOM element.
<body></body>
// Prepend content
let body = prependSync(document.body, '!', 'world', ' ', 'Hello');