
Security News
Static vs. Runtime Reachability: Insights from Latio’s On the Record Podcast
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Create HTML in JavaScript via virtual-dom VTrees or directly to the DOM: virtual-hyperscript alternative
Alpha
Create HTML in JavaScript via virtual-dom VTrees or directly to the DOM: virtual-hyperscript alternative.
See: Hypertext with ES6, ES5, CommonJS, AMD & globals
Demo using npm run play
tweak ./playground.js
then check port 9966
To demo directly use ./dist/hypertext-not-for-production.min.js
all tags will miserably be global.
npm i --save hypertext
: Installnpm run build
: Builds all distributionsnpm run play
: Host playground.js on port 9966import { div, ul, li, a, header, footer, article, section, aside, h1, h3} from 'hypertext';
import { createNodes, div, h1, p, figure, figcaption, img } from 'hypertext';
const helloWorldTree =
div({ class: 'hello', id: 'world' },
h1('Hello World!'),
p('How are you?'),
figure({ class: 'img-section' },
figcaption('Three different breeds of dogs.'),
img({ alt: 'Maltese Terrier', src: 'dog1.jpg' }),
img({ alt: 'Black Labrador', src: 'dog2.jpg' })
)
);
let helloWorldNodes = createNodes(helloWorldTree);
document.body.appendChild(helloWorldNodes);
Will create:
<div class="hello" id="world">
<h1>Hello World!</h1>
<p>How are you?</p>
<figure class="img-section">
<figcaption>Three different breeds of dogs</figcaption>
<img alt="Maltese Terrier" src="dog1.jpg">
<img alt="Black Labrador" src="dog2.jpg">
</figure>
</div>
Hypertext currently supports any virtual dom based on virtual-dom's VTrees. Such as:
A modification of virtual-dom's example:
import { div } from 'hypertext';
import { diff, patch, createElement } from 'virtual-dom';
// 1: Create a function that declares what the DOM should look like
function render(count) {
return (
div({style: {textAlign: 'center', lineHeight: (100 + count) + 'px',
border: '1px solid red', width: (100 + count) + 'px', height: (100 + count) + 'px'}},
[String(count)]
)
)
}
// 2: Initialise the document
var count = 0;
var tree = render(count); // We need an initial tree
var rootNode = createElement(tree); // Create an initial root DOM node ...
document.body.appendChild(rootNode); // ... and it should be in the document
// 3: Wire up the update logic
setInterval(function () {
count++;
var newTree = render(count);
var patches = diff(tree, newTree);
rootNode = patch(rootNode, patches);
tree = newTree;
}, 1000);
Hypertext features identical tag notation to HTML without the use of a transformer as with JSX. There's a few good reasons to use Hypertext
</closingTag>
=== )
.npm run es
: Builds hypertext.es.jsnpm run umd
: Builds hypertext.jsnpm run globals
: Builds not-for-production.min.jsnpm run watch
: Build and watch src for esTo Matt Esch and Jake Verbaten for creating a bunch of cool libraries and modules that made Hypertext feasible.
MIT Copyright (c) 2016 Julien Etienne
FAQs
Create HTML in JavaScript via virtual-dom VTrees or directly to the DOM: virtual-hyperscript alternative
The npm package hypertext receives a total of 7 weekly downloads. As such, hypertext popularity was classified as not popular.
We found that hypertext demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.