DEV Community

Discussion on: Learn basic Web Components

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

These APIs are all very low-level and using them directly isn't all that practical. I usually prefer creating some simple wrappers around them, small and simple enough that I can just copy-paste them into any random project without having to worry about updating them.

For the HTMLElement class I've created this "improved" version that takes care of as much of the typical preamble without sacrificing too much flexibility or building a whole new framework.

Collapse
 
dannyengelman profile image
Danny Engelman • Edited

Low-Level ??

They are part of the JavaScript engine, no lower than an Array or any other API

A low-level programming language is a programming language that provides little or no abstraction from a computer's instruction set architecture—commands or functions in the language map that are structurally similar to processor's instructions. Generally, this refers to either machine code or assembly language.

You can "improve" your code:

content.forEach( element => this.appendChild(element) );
Enter fullscreen mode Exit fullscreen mode

to

this.append(...content);
Enter fullscreen mode Exit fullscreen mode

MDN append documentation