
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
nss-domcomponent
Advanced tools
This libray is for use by Nashville Software School students to learn the basics of extending a 3rd party npm package for use in their Browserify projects. Its sole purpose is to create HTML elements to build your DOM structure for your views.
Make sure you are in the lib directory of your project.
cd src/lib
Then install this package.
npm i nss-domcomponents -D
Let's look at a quick, basic example. Assume you want to create a component for displaying recent news articles.
<article class="newsarticle">
<header class="newsarticle__title">
<h1>Giant Meteor on Track to Demolish Earth</h1>
</header>
<section class="newsarticle__section">
<p>NASA scientists have discovered meteor
HSA-01992x-9981 just beyond the orbit of Jupiter
whose calculated trajectory has it plummeting into
the eastern Pacific ocean next January.</p>
<p>We urge everyone to start digging underground
shelters and stockpile food, water, and energy
sources to survive the impending apocolypse.</p>
</section>
<footer class="newsarticle__footer">
Source - Science Methodology Today - 10/04/2004
</footer>
</article>
First, you will extend the component creator class in the nss-domcomponent library to create a definition for an <article> element.
import DOMComponent from "nss-domcomponent"
/* Blueprint for an <article> element */
class article extends DOMComponent {
constructor(attributes, ...children) {
super("article", attributes, ...children)
}
}
You also need the following elements: header, h1, section, footer, and p.
/* Blueprint for an <p> element */
class p extends DOMComponent {
constructor(attributes, ...children) {
super("p", attributes, ...children)
}
}
/* Blueprint for an <header> element */
class header extends DOMComponent {
constructor(attributes, ...children) {
super("header", attributes, ...children)
}
}
/* Blueprint for an <h1> element */
class h1 extends DOMComponent {
constructor(attributes, ...children) {
super("h1", attributes, ...children)
}
}
/* Blueprint for an <section> element */
class section extends DOMComponent {
constructor(attributes, ...children) {
super("section", attributes, ...children)
}
}
/* Blueprint for an <footer> element */
class footer extends DOMComponent {
constructor(attributes, ...children) {
super("footer", attributes, ...children)
}
}
Now that you've defined the class for all of the different element types you need to create the HTML structure above, you can start creating instances to build it.
const firstParagraph = new p("NASA scientists have discovered meteor HSA-01992x-9981 just beyond the orbit of Jupiter whose calculated trajectory has it plummeting into the eastern Pacific ocean next January.")
const secondParagraph = new p("We urge everyone to start digging underground shelters and stockpile food, water, and energy sources to survive the impending apocolypse.")
/* You can add components as children of other components */
const articleSection = new section(
{
className: "newsarticle__section"
},
firstParagraph,
secondParagraph
)
From the code you've built so far, it would generate the following HTML structure.
<section class="newsarticle__section">
<p></p>
<p></p>
</section>
Now you can create the rest of the elements that will go inside the top-level article.
const title = new h1("Giant Meteor on Track to Demolish Earth")
const articleHeader = new header(
{
className: "newsarticle__title"
},
title // Child element
)
const articleFooter = new footer({
className: "newsarticle__footer",
textContent: "Source - Science Methodology Today - 10/04/2004"
})
Now that the header, the section, and the footer are all constructed, it's time to place them all inside the article.
const mainArticle = new article({
className: "newsarticle"
},
// You can add as many children as you want
articleHeader,
articleSection,
articleFooter
)
The DOMComponent class also has a render() method on it where you specify where you want your new HTML structure added to the DOM. Assume that you have a <div class="output"> element in your index.html file.
const mainArticle = new article({
className: "newsarticle"
},
articleHeader,
articleSection,
articleFooter
).render(".output") // Using dot notation, invoke render()
FAQs
HTML component creation library
The npm package nss-domcomponent receives a total of 1 weekly downloads. As such, nss-domcomponent popularity was classified as not popular.
We found that nss-domcomponent 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.