Skip to content
This repository was archived by the owner on Dec 17, 2021. It is now read-only.

Files

Latest commit

author
Oxford
Aug 3, 2020
43e69fd · Aug 3, 2020

History

History
38 lines (24 loc) · 1.08 KB

prependsync.md

File metadata and controls

38 lines (24 loc) · 1.08 KB

DOM/prependSync()

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

import prependSync from '@web-native-js/play-ui/src/dom/prependSync.js';

Syntax

prependSync(el[, ...content);

Parameters

  • 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.

Return

  • HTMLElement - The target DOM element.

Usage

<body></body>
// Prepend content
let body = prependSync(document.body, '!', 'world', ' ', 'Hello');