create-element-ns
Advanced tools
Comparing version 2.0.1 to 2.1.1
var global = require('dom-document'), | ||
createElement = require('./src/create-element'), | ||
createTree = require('./src/create-tree'), | ||
factory = require('./src/create-factory'), | ||
@@ -13,4 +12,4 @@ decorators = require('./src/decorators'), | ||
var el = factory(createTree) | ||
el.svg = factory(createTree, {xmlns: 'http://www.w3.org/2000/svg'}) | ||
var el = factory() | ||
el.svg = factory({xmlns: 'http://www.w3.org/2000/svg'}) | ||
@@ -24,3 +23,2 @@ module.exports = { | ||
createElement: createElement, | ||
createTree: createTree, | ||
mergeKeys: mergeKeys, | ||
@@ -27,0 +25,0 @@ parseArgument: parseArgument, |
{ | ||
"name": "create-element-ns", | ||
"version": "2.0.1", | ||
"version": "2.1.1", | ||
"description": "dom createElement hyperscript with svg, namespace and selector support", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
var mergeKeys = require('./merge-keys'), | ||
parseArgument = require('./parse-argument') | ||
parseArgument = require('./parse-argument'), | ||
decorate = require('./decorate'), | ||
setChildren = require('./set-children'), | ||
createElement = require('./create-element') | ||
@@ -8,7 +11,6 @@ module.exports = createFactory | ||
* creator to inject settings applicable to many instances (namespace, ...) | ||
* @param {function} creator - shared settings | ||
* @param {Object} defaults - shared settings | ||
* @returns {function} defining function | ||
*/ | ||
function createFactory(creator, defaults) { | ||
function createFactory(defaults) { | ||
/** | ||
@@ -26,7 +28,10 @@ * definition for a given factory | ||
* Factory function to produce instances of the defined Component | ||
* @param {any} [cfg] - optional additional individual configuration | ||
* @param {any} [opt] - optional additional individual configuration | ||
* @returns {function} individual view function | ||
*/ | ||
function factory(cfg) { | ||
return creator(context, cfg) | ||
function factory(opt) { | ||
var el = createElement(context) | ||
decorate(el, context) | ||
if (context.content) setChildren(el, context.content) | ||
return opt ? decorate(el, opt) : el | ||
} | ||
@@ -33,0 +38,0 @@ factory.isFactory = true |
@@ -13,7 +13,7 @@ var is = require('./is'), | ||
if (is.object(arg)) return arg | ||
default: // all arguments after the optional element and config are children | ||
if (Array.isArray(arg)) return {content: arg} | ||
if (is.stringlike(arg) || is.node(arg) || is.function(arg)) return {content: [arg]} | ||
} | ||
// all arguments after the optional element and config are children | ||
if (Array.isArray(arg)) return {content: arg} | ||
if (is.stringlike(arg) || is.node(arg) || is.function(arg)) return {content: [arg]} | ||
return {} | ||
} |
14778
15
329