Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
create-element-ns
Advanced tools
dom createElement hyperscript with svg, namespace and selector support
dom createElement
and createElementNS
hyperscript with svg, namespace and selector support
• Example • Features • API • License
var createElementNS = require('create-element-ns')
var html = createElementNS.html,
createHtmlFac = createElementNS.html({partial: true}),
svg = createElementNS.svg
// selectors or attributes
var divEl1 = html('div.c1#i1[style="color:blue"].c2', {onclick: function() {}}),
divEl2 = html('div.i1', {style: {color: 'blue'}, props:{className: 'c1 c2', , onclick: function() {}}})
// namespace in different ways
var circleEl1 = html('svg:circle'),
circleEl2 = svg('svg:circle'),
circleEl3 = html('circle[xmlns=http://www.w3.org/2000/svg]')
circleEl3 = html('circle', {element: {xmlns : 'http://www.w3.org/2000/svg'}})
// partial application to reate multiple modified clones
var pFactory = html('p', {textContent: 'x', partial: true}),
pEl1 = pFactory({textContent: 'x'})
document API
for server and/or testing (e.g. jsdom
)There are many hyperscript modules out there (docrel, create-element-from-selector, domator, makeelement, simpel to name a few) but they either don't support namespaces, like svg or are more oriented to virtual-dom applications.
To create an element (methods that return a DOM Element):
html(definition [, options][, content])
=> HTMLElement
|| elementFactory
svg(definition [, options][, content])
=> SVGElement
|| elementFactory
If there is no tagName defined or if there is a partial property {partial: true}
in the arguments,
the function returns a factory instead of an element.
Parameters and outputs
definition
: a string selector, elementFactory
or DOM Elementoptions
: an optional qualifier
object of attributes and properties or an optional elementDecorator
function
qualifier
: {properties:{}, attributes:{}, style:{}, dataset:{}}. Alias s
, a
, p
, d
, props
, attrs
elementDecorator(el) => el'
modifies an element directlycontent
: optional series of string, Element and arrays of strings and ElementselementFactory([elementDecorator|optionObject]) => el
.api(documentAPI)
injects an external document API like jsdom
. Uses the global document
if not specified..ns(prefix, URI)
adds additional namespace prefix (svg is already defined). E.g. .ns('xlink', 'http://www.w3.org/1999/xlink')
.factory(nsDecorators, partial, URI)
to create additional namespace functions (html and svg are already defined)Released under the MIT License
FAQs
dom createElement hyperscript with svg, namespace and selector support
The npm package create-element-ns receives a total of 0 weekly downloads. As such, create-element-ns popularity was classified as not popular.
We found that create-element-ns 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.