Installations
npm install create-element-ns
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
13.11.0
NPM Version
6.13.7
Score
71.9
Supply Chain
88.7
Quality
75.8
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Developer
hville
Download Statistics
Total Downloads
8,574
Last Day
2
Last Week
13
Last Month
45
Last Year
316
GitHub Statistics
61 Commits
2 Watching
1 Branches
1 Contributors
Bundle Size
3.68 kB
Minified
1.50 kB
Minified + Gzipped
Package Meta Information
Latest Version
3.3.1
Package Id
create-element-ns@3.3.1
Unpacked Size
17.05 kB
Size
6.11 kB
File Count
20
NPM Version
6.13.7
Node Version
13.11.0
Total Downloads
Cumulative downloads
Total Downloads
8,574
Last day
-66.7%
2
Compared to previous day
Last week
-58.1%
13
Compared to previous week
Last month
1,025%
45
Compared to previous month
Last year
-56.2%
316
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
1
create-element-ns
dom createElement
and createElementNS
hyperscript with svg, namespace and selector support
• Example • Features • API • License
Example
1var CE = require('create-element-ns') 2var el = CE.el 3 4// selectors or attributes 5var divEl1 = el('div.c1#i1[style="color:blue"].c2', {onclick: function() {}})(), 6 divEl2 = el('div.i1', {style: {color: 'blue'}, props:{className: 'c1 c2', , onclick: function() {}}})(), 7 divEl3 = el('div.c1#i1[style="color:blue"].c2')({onclick: function() {}}), 8 9// namespace in different ways 10var circleEl1 = el('svg:circle')(), 11 circleEl2 = el.svg('circle')(), 12 circleEl3 = el('circle[xmlns=http://www.w3.org/2000/svg]') 13 circleEl3 = el('circle', {xmlns : 'http://www.w3.org/2000/svg'}) 14 15// partial application to create multiple modified clones 16var pFn = el('p'), 17 pEl = pFn({textContent: 'x'}) 18 19// factory functions can be nested, with or without arrays 20var olFn = el('ol', el('li', 'one'), [el('li', 'two'), el('li', 'three')]), 21 olEl = pFn()
Features
- namespaced tag and namespaced attribute support
- svg namespace and utility functions pre-defined
- w3 string selector API, including attributes
- element decorators for element properties and attributes
- ability to inject a
document API
for server and/or testing (e.g.jsdom
) - ability to create an element or an element factory
- ability to create additional namespaces and utility namespaced functions
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.
API
Main methods
To create an element factory (function that return a DOM Element):
el(definition [, options][, content])
=>elementFactory
el.svg(definition [, options][, content])
=>elementFactory
elementFactory([optionObject])
=>DOM Element
Parameters and outputs
definition
: a string selector,elementFactory
or DOM Elementoptions
:{properties:{}, attributes:{}, style:{}, dataset:{}}
or{props:{}, attrs:{}, style:{}, dataset:{}}
content
: optional series or array of string,Element
orelementFactory
Optional additional utilities
CE.global.document
injects an external document API likejsdom
. Uses the globaldocument
if not specified.CE.namespaces
adds additional namespace prefix (svg is already defined). E.g.CE.namespaces.xlink: 'http://www.w3.org/1999/xlink'
CE.decorators
to add element decorators E.g.CE.decorators.a = CE.decorators.attributes
License
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
2.6
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More