Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

create-element-ns

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-element-ns - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

3

index.js

@@ -6,3 +6,4 @@ var factory = require('./elm'),

common: common,
createElement: factory()
html: factory(),
svg: factory({element: {xmlns: common.namespaces.svg}})
}
{
"name": "create-element-ns",
"version": "0.4.0",
"version": "0.5.0",
"description": "dom createElement hyperscript with svg, namespace and selector support",

@@ -5,0 +5,0 @@ "keywords": [

@@ -14,19 +14,19 @@ <!-- markdownlint-disable MD004 MD007 MD010 MD041 MD022 MD024 MD032 MD036 -->

var createHtmlEl = createElementNS.html.el,
createHtmlFac = createElementNS.html.el,
createSvgEl = createElementNS.svg.fn,
createSvgFac = createElementNS.svg.fn,
var html = createElementNS.html,
createHtmlFac = createElementNS.html({partial: true}),
svg = createElementNS.svg
// selectors or attributes
var divEl1 = createHtmlEl('div.c1#i1[style="color:blue"].c2', {onclick: function() {}}),
divEl2 = createHtmlEl('div.i1', {style: {color: 'blue'}, props:{className: 'c1 c2', , onclick: function() {}}})
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 = createHtmlEl('svg:circle'),
circleEl2 = createSvgEl('svg:circle'),
circleEl3 = createHtmlEl('circle[xmlns=http://www.w3.org/2000/svg]')
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'}})
// elementfactories to create multiple modified clones
var pEl0 = pFac('p', {textContent: 'x', partial: true}),
pEl1 = pFac({textContent: 'x'})
// partial application to reate multiple modified clones
var pFactory = html('p', {textContent: 'x', partial: true}),
pEl1 = pFactory({textContent: 'x'})
```

@@ -53,8 +53,7 @@

To create an element (methods that return a DOM Element):
* `html.el(definition [, options][, content])` => DOM HTMLElement
* `svg.el(definition [, options][, content])` => DOM SVGElement
* `html(definition [, options][, content])` => `HTMLElement` || `elementFactory`
* `svg(definition [, options][, content])` => `SVGElement` || `elementFactory`
To create an element factory (methods that return an `elementFactory` that creates DOM Elements):
* `html.fn(definition [, options][, content])` => `elementFactory`
* `svg.fn(definition [, options][, content])` => `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.

@@ -61,0 +60,0 @@ Parameters and outputs

@@ -7,4 +7,4 @@ var jsdom = require('jsdom'),

DOM = document.defaultView,
htm = ceNS.createElement,
svg = htm({element: {xmlns: ceNS.common.namespaces.svg}, partial: true})
htm = ceNS.html,
svg = ceNS.svg

@@ -11,0 +11,0 @@ ceNS.common.document = document

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc