magic-virtual-element
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -1,2 +0,2 @@ | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.magicVirtualElement = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof _require=="function"&&_require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof _require=="function"&&_require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_require,module,exports){ | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.magicVirtualElement = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
var toStyle = _require('to-style').string | ||
@@ -6,4 +6,12 @@ var classnames = _require('classnames') | ||
var type = _require('component-type') | ||
var slice = _require('sliced') | ||
module.exports = function (t, attributes, children) { | ||
// Account for JSX putting the children as multiple arguments. | ||
// This is essentially just the ES6 rest param | ||
if (arguments.length > 2 && Array.isArray(arguments[2]) === false) { | ||
children = slice(arguments, 2) | ||
} | ||
var node = element(t, attributes, children) | ||
@@ -26,807 +34,3 @@ | ||
},{"classnames":2,"component-type":3,"to-style":4,"virtual-element":21}],2:[function(_require,module,exports){ | ||
/*! | ||
Copyright (c) 2015 Jed Watson. | ||
Licensed under the MIT License (MIT), see | ||
http://jedwatson.github.io/classnames | ||
*/ | ||
(function () { | ||
'use strict'; | ||
function classNames () { | ||
var classes = ''; | ||
for (var i = 0; i < arguments.length; i++) { | ||
var arg = arguments[i]; | ||
if (!arg) continue; | ||
var argType = typeof arg; | ||
if ('string' === argType || 'number' === argType) { | ||
classes += ' ' + arg; | ||
} else if (Array.isArray(arg)) { | ||
classes += ' ' + classNames.apply(null, arg); | ||
} else if ('object' === argType) { | ||
for (var key in arg) { | ||
if (arg.hasOwnProperty(key) && arg[key]) { | ||
classes += ' ' + key; | ||
} | ||
} | ||
} | ||
} | ||
return classes.substr(1); | ||
} | ||
if (typeof module !== 'undefined' && module.exports) { | ||
module.exports = classNames; | ||
} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd){ | ||
// AMD. Register as an anonymous module. | ||
define(function () { | ||
return classNames; | ||
}); | ||
} else { | ||
window.classNames = classNames; | ||
} | ||
}()); | ||
},{}],3:[function(_require,module,exports){ | ||
/** | ||
* toString ref. | ||
*/ | ||
var toString = Object.prototype.toString; | ||
/** | ||
* Return the type of `val`. | ||
* | ||
* @param {Mixed} val | ||
* @return {String} | ||
* @api public | ||
*/ | ||
module.exports = function(val){ | ||
switch (toString.call(val)) { | ||
case '[object Date]': return 'date'; | ||
case '[object RegExp]': return 'regexp'; | ||
case '[object Arguments]': return 'arguments'; | ||
case '[object Array]': return 'array'; | ||
case '[object Error]': return 'error'; | ||
} | ||
if (val === null) return 'null'; | ||
if (val === undefined) return 'undefined'; | ||
if (val !== val) return 'nan'; | ||
if (val && val.nodeType === 1) return 'element'; | ||
val = val.valueOf | ||
? val.valueOf() | ||
: Object.prototype.valueOf.apply(val) | ||
return typeof val; | ||
}; | ||
},{}],4:[function(_require,module,exports){ | ||
'use strict' | ||
module.exports = { | ||
prefixProperties: _require('./src/prefixProperties') , | ||
cssUnitless: _require('./src/cssUnitless') , | ||
object: _require('./src/toStyleObject'), | ||
string: _require('./src/toStyleString') | ||
} | ||
},{"./src/cssUnitless":6,"./src/prefixProperties":11,"./src/toStyleObject":19,"./src/toStyleString":20}],5:[function(_require,module,exports){ | ||
module.exports = _require('./prefixer')() | ||
},{"./prefixer":12}],6:[function(_require,module,exports){ | ||
'use exports' | ||
//make sure properties are in hyphenated form | ||
module.exports = { | ||
'animation' : 1, | ||
'column-count' : 1, | ||
'columns' : 1, | ||
'font-weight' : 1, | ||
'opacity' : 1, | ||
'order ' : 1, | ||
'z-index' : 1, | ||
'zoom' : 1, | ||
'flex' : 1, | ||
'box-flex' : 1, | ||
'transform' : 1, | ||
'perspective' : 1, | ||
'box-pack' : 1, | ||
'box-align' : 1, | ||
'colspan' : 1, | ||
'rowspan' : 1 | ||
} | ||
},{}],7:[function(_require,module,exports){ | ||
'use strict' | ||
var objectHasOwn = Object.prototype.hasOwnProperty | ||
module.exports = function(object, propertyName){ | ||
return objectHasOwn.call(object, propertyName) | ||
} | ||
},{}],8:[function(_require,module,exports){ | ||
'use strict' | ||
var objectToString = Object.prototype.toString | ||
module.exports = function(v) { | ||
return objectToString.apply(v) === '[object Function]' | ||
} | ||
},{}],9:[function(_require,module,exports){ | ||
'use strict' | ||
var objectToString = Object.prototype.toString | ||
module.exports = function(v){ | ||
return !!v && objectToString.call(v) === '[object Object]' | ||
} | ||
},{}],10:[function(_require,module,exports){ | ||
'use strict'; | ||
var toUpperFirst = _require('./stringUtils/toUpperFirst') | ||
var re = /^(Moz|Webkit|Khtml|O|ms|Icab)(?=[A-Z])/ | ||
var docStyle = typeof document == 'undefined'? | ||
{}: | ||
document.documentElement.style | ||
var prefixInfo = (function(){ | ||
var prefix = (function(){ | ||
for (var prop in docStyle) { | ||
if( re.test(prop) ) { | ||
// test is faster than match, so it's better to perform | ||
// that on the lot and match only when necessary | ||
return prop.match(re)[0] | ||
} | ||
} | ||
// Nothing found so far? Webkit does not enumerate over the CSS properties of the style object. | ||
// However (prop in style) returns the correct value, so we'll have to test for | ||
// the precence of a specific property | ||
if ('WebkitOpacity' in docStyle){ | ||
return 'Webkit' | ||
} | ||
if ('KhtmlOpacity' in docStyle) { | ||
return 'Khtml' | ||
} | ||
return '' | ||
})(), | ||
lower = prefix.toLowerCase() | ||
return { | ||
style : prefix, | ||
css : '-' + lower + '-', | ||
dom : ({ | ||
Webkit: 'WebKit', | ||
ms : 'MS', | ||
o : 'WebKit' | ||
})[prefix] || toUpperFirst(prefix) | ||
} | ||
})() | ||
module.exports = prefixInfo | ||
},{"./stringUtils/toUpperFirst":18}],11:[function(_require,module,exports){ | ||
module.exports = { | ||
'border-radius' : 1, | ||
'border-top-left-radius' : 1, | ||
'border-top-right-radius' : 1, | ||
'border-bottom-left-radius' : 1, | ||
'border-bottom-right-radius' : 1, | ||
'box-shadow' : 1, | ||
'order' : 1, | ||
'flex' : function(name, prefix){ | ||
return [prefix + 'box-flex'] | ||
}, | ||
'box-flex' : 1, | ||
'box-align' : 1, | ||
'animation' : 1, | ||
'animation-duration' : 1, | ||
'animation-name' : 1, | ||
'transition' : 1, | ||
'transition-duration' : 1, | ||
'transform' : 1, | ||
'transform-style' : 1, | ||
'transform-origin' : 1, | ||
'backface-visibility' : 1, | ||
'perspective' : 1, | ||
'box-pack' : 1 | ||
} | ||
},{}],12:[function(_require,module,exports){ | ||
'use strict' | ||
var camelize = _require('./stringUtils/camelize') | ||
var hyphenate = _require('./stringUtils/hyphenate') | ||
var toLowerFirst = _require('./stringUtils/toLowerFirst') | ||
var toUpperFirst = _require('./stringUtils/toUpperFirst') | ||
var prefixInfo = _require('./prefixInfo') | ||
var prefixProperties = _require('./prefixProperties') | ||
var docStyle = typeof document == 'undefined'? | ||
{}: | ||
document.documentElement.style | ||
module.exports = function(asStylePrefix){ | ||
return function(name, config){ | ||
config = config || {} | ||
var styleName = toLowerFirst(camelize(name)), | ||
cssName = hyphenate(name), | ||
theName = asStylePrefix? | ||
styleName: | ||
cssName, | ||
thePrefix = prefixInfo.style? | ||
asStylePrefix? | ||
prefixInfo.style: | ||
prefixInfo.css | ||
: | ||
'' | ||
if ( styleName in docStyle ) { | ||
return config.asString? | ||
theName : | ||
[ theName ] | ||
} | ||
//not a valid style name, so we'll return the value with a prefix | ||
var upperCased = theName, | ||
prefixProperty = prefixProperties[cssName], | ||
result = [] | ||
if (asStylePrefix){ | ||
upperCased = toUpperFirst(theName) | ||
} | ||
if (typeof prefixProperty == 'function'){ | ||
var prefixedCss = prefixProperty(theName, thePrefix) || [] | ||
if (prefixedCss && !Array.isArray(prefixedCss)){ | ||
prefixedCss = [prefixedCss] | ||
} | ||
if (prefixedCss.length){ | ||
prefixedCss = prefixedCss.map(function(property){ | ||
return asStylePrefix? | ||
toLowerFirst(camelize(property)): | ||
hyphenate(property) | ||
}) | ||
} | ||
result = result.concat(prefixedCss) | ||
} | ||
if (thePrefix){ | ||
result.push(thePrefix + upperCased) | ||
} | ||
result.push(theName) | ||
if (config.asString || result.length == 1){ | ||
return result[0] | ||
} | ||
return result | ||
} | ||
} | ||
},{"./prefixInfo":10,"./prefixProperties":11,"./stringUtils/camelize":13,"./stringUtils/hyphenate":15,"./stringUtils/toLowerFirst":17,"./stringUtils/toUpperFirst":18}],13:[function(_require,module,exports){ | ||
'use strict' | ||
var toCamelFn = function(str, letter){ | ||
return letter ? letter.toUpperCase(): '' | ||
} | ||
var hyphenRe = _require('./hyphenRe') | ||
module.exports = function(str){ | ||
return str? | ||
str.replace(hyphenRe, toCamelFn): | ||
'' | ||
} | ||
},{"./hyphenRe":14}],14:[function(_require,module,exports){ | ||
module.exports = /[-\s]+(.)?/g | ||
},{}],15:[function(_require,module,exports){ | ||
'use strict' | ||
var separate = _require('./separate') | ||
module.exports = function(name){ | ||
return separate(name).toLowerCase() | ||
} | ||
},{"./separate":16}],16:[function(_require,module,exports){ | ||
'use strict' | ||
var doubleColonRe = /::/g | ||
var upperToLowerRe = /([A-Z]+)([A-Z][a-z])/g | ||
var lowerToUpperRe = /([a-z\d])([A-Z])/g | ||
var underscoreToDashRe = /_/g | ||
module.exports = function(name, separator){ | ||
return name? | ||
name.replace(doubleColonRe, '/') | ||
.replace(upperToLowerRe, '$1_$2') | ||
.replace(lowerToUpperRe, '$1_$2') | ||
.replace(underscoreToDashRe, separator || '-') | ||
: | ||
'' | ||
} | ||
},{}],17:[function(_require,module,exports){ | ||
'use strict' | ||
module.exports = function(value){ | ||
return value.length? | ||
value.charAt(0).toLowerCase() + value.substring(1): | ||
value | ||
} | ||
},{}],18:[function(_require,module,exports){ | ||
'use strict' | ||
module.exports = function(value){ | ||
return value.length? | ||
value.charAt(0).toUpperCase() + value.substring(1): | ||
value | ||
} | ||
},{}],19:[function(_require,module,exports){ | ||
'use strict' | ||
var prefixInfo = _require('./prefixInfo') | ||
var cssPrefixFn = _require('./cssPrefix') | ||
var HYPHENATE = _require('./stringUtils/hyphenate') | ||
var CAMELIZE = _require('./stringUtils/camelize') | ||
var HAS_OWN = _require('./hasOwn') | ||
var IS_OBJECT = _require('./isObject') | ||
var IS_FUNCTION = _require('./isFunction') | ||
var applyPrefix = function(target, property, value, normalizeFn){ | ||
cssPrefixFn(property).forEach(function(p){ | ||
target[normalizeFn? normalizeFn(p): p] = value | ||
}) | ||
} | ||
var toObject = function(str){ | ||
str = (str || '').split(';') | ||
var result = {} | ||
str.forEach(function(item){ | ||
var split = item.split(':') | ||
if (split.length == 2){ | ||
result[split[0].trim()] = split[1].trim() | ||
} | ||
}) | ||
return result | ||
} | ||
var CONFIG = { | ||
cssUnitless: _require('./cssUnitless') | ||
} | ||
/** | ||
* @ignore | ||
* @method toStyleObject | ||
* | ||
* @param {Object} styles The object to convert to a style object. | ||
* @param {Object} [config] | ||
* @param {Boolean} [config.addUnits=true] True if you want to add units when numerical values are encountered. | ||
* @param {Object} config.cssUnitless An object whose keys represent css numerical property names that will not be appended with units. | ||
* @param {Object} config.prefixProperties An object whose keys represent css property names that should be prefixed | ||
* @param {String} config.cssUnit='px' The css unit to append to numerical values. Defaults to 'px' | ||
* @param {String} config.normalizeName A function that normalizes a name to a valid css property name | ||
* @param {String} config.scope | ||
* | ||
* @return {Object} The object, normalized with css style names | ||
*/ | ||
var TO_STYLE_OBJECT = function(styles, config, prepend, result){ | ||
if (typeof styles == 'string'){ | ||
styles = toObject(styles) | ||
} | ||
config = config || CONFIG | ||
config.cssUnitless = config.cssUnitless || CONFIG.cssUnitless | ||
result = result || {} | ||
var scope = config.scope || {}, | ||
//configs | ||
addUnits = config.addUnits != null? | ||
config.addUnits: | ||
scope && scope.addUnits != null? | ||
scope.addUnits: | ||
true, | ||
cssUnitless = (config.cssUnitless != null? | ||
config.cssUnitless: | ||
scope? | ||
scope.cssUnitless: | ||
null) || {}, | ||
cssUnit = (config.cssUnit || scope? scope.cssUnit: null) || 'px', | ||
prefixProperties = (config.prefixProperties || (scope? scope.prefixProperties: null)) || {}, | ||
camelize = config.camelize, | ||
normalizeFn = camelize? CAMELIZE: HYPHENATE | ||
// Object.keys(cssUnitless).forEach(function(key){ | ||
// cssUnitless[normalizeFn(key)] = 1 | ||
// }) | ||
var processed, | ||
styleName, | ||
propName, | ||
propValue, | ||
propCssUnit, | ||
propType, | ||
propIsNumber, | ||
fnPropValue, | ||
prefix | ||
for (propName in styles) if (HAS_OWN(styles, propName)) { | ||
propValue = styles[ propName ] | ||
//the hyphenated style name (css property name) | ||
styleName = HYPHENATE(prepend? prepend + propName: propName) | ||
processed = false | ||
prefix = false | ||
if (IS_FUNCTION(propValue)) { | ||
//a function can either return a css value | ||
//or an object with { value, prefix, name } | ||
fnPropValue = propValue.call(scope || styles, propValue, propName, styleName, styles) | ||
if (IS_OBJECT(fnPropValue) && fnPropValue.value != null){ | ||
propValue = fnPropValue.value | ||
prefix = fnPropValue.prefix | ||
styleName = fnPropValue.name? | ||
HYPHENATE(fnPropValue.name): | ||
styleName | ||
} else { | ||
propValue = fnPropValue | ||
} | ||
} | ||
propType = typeof propValue | ||
propIsNumber = propType == 'number' || (propType == 'string' && propValue != '' && propValue * 1 == propValue) | ||
if (propValue == null || styleName == null || styleName === ''){ | ||
continue | ||
} | ||
if (propIsNumber || propType == 'string'){ | ||
processed = true | ||
} | ||
if (!processed && propValue.value != null && propValue.prefix){ | ||
processed = true | ||
prefix = propValue.prefix | ||
propValue = propValue.value | ||
} | ||
// hyphenStyleName = camelize? HYPHENATE(styleName): styleName | ||
if (processed){ | ||
prefix = prefix || !!prefixProperties[styleName] | ||
if (propIsNumber){ | ||
propValue = addUnits && !(styleName in cssUnitless) ? | ||
propValue + cssUnit: | ||
propValue + ''//change it to a string, so that jquery does not append px or other units | ||
} | ||
//special border treatment | ||
if ( | ||
( | ||
styleName == 'border' || | ||
(!styleName.indexOf('border') | ||
&& | ||
!~styleName.indexOf('radius') | ||
&& | ||
!~styleName.indexOf('width')) | ||
) && | ||
propIsNumber | ||
){ | ||
styleName = styleName + '-width' | ||
} | ||
//special border radius treatment | ||
if (!styleName.indexOf('border-radius-')){ | ||
styleName.replace(/border(-radius)(-(.*))/, function(str, radius, theRest){ | ||
var positions = { | ||
'-top' : ['-top-left', '-top-right' ], | ||
'-left' : ['-top-left', '-bottom-left' ], | ||
'-right' : ['-top-right', '-bottom-right'], | ||
'-bottom' : ['-bottom-left', '-bottom-right'] | ||
} | ||
if (theRest in positions){ | ||
styleName = [] | ||
positions[theRest].forEach(function(pos){ | ||
styleName.push('border' + pos + radius) | ||
}) | ||
} else { | ||
styleName = 'border'+ theRest + radius | ||
} | ||
}) | ||
if (Array.isArray(styleName)){ | ||
styleName.forEach(function(styleName){ | ||
if (prefix){ | ||
applyPrefix(result, styleName, propValue, normalizeFn) | ||
} else { | ||
result[normalizeFn(styleName)] = propValue | ||
} | ||
}) | ||
continue | ||
} | ||
} | ||
if (prefix){ | ||
applyPrefix(result, styleName, propValue, normalizeFn) | ||
} else { | ||
result[normalizeFn(styleName)] = propValue | ||
} | ||
} else { | ||
//the propValue must be an object, so go down the hierarchy | ||
TO_STYLE_OBJECT(propValue, config, styleName + '-', result) | ||
} | ||
} | ||
return result | ||
} | ||
module.exports = TO_STYLE_OBJECT | ||
},{"./cssPrefix":5,"./cssUnitless":6,"./hasOwn":7,"./isFunction":8,"./isObject":9,"./prefixInfo":10,"./stringUtils/camelize":13,"./stringUtils/hyphenate":15}],20:[function(_require,module,exports){ | ||
'use strict' | ||
var toStyleObject = _require('./toStyleObject') | ||
var hasOwn = _require('./hasOwn') | ||
/** | ||
* @ignore | ||
* @method toStyleString | ||
* | ||
* @param {Object} styles The object to convert to a style string. | ||
* @param {Object} config | ||
* @param {Boolean} config.addUnits=true True if you want to add units when numerical values are encountered. Defaults to true | ||
* @param {Object} config.cssUnitless An object whose keys represent css numerical property names that will not be appended with units. | ||
* @param {Object} config.prefixProperties An object whose keys represent css property names that should be prefixed | ||
* @param {String} config.cssUnit='px' The css unit to append to numerical values. Defaults to 'px' | ||
* @param {String} config.scope | ||
* | ||
* @return {Object} The object, normalized with css style names | ||
*/ | ||
module.exports = function(styles, config){ | ||
styles = toStyleObject(styles, config) | ||
var result = [] | ||
var prop | ||
for(prop in styles) if (hasOwn(styles, prop)){ | ||
result.push(prop + ': ' + styles[prop]) | ||
} | ||
return result.join('; ') | ||
} | ||
},{"./hasOwn":7,"./toStyleObject":19}],21:[function(_require,module,exports){ | ||
/** | ||
* Module dependencies. | ||
*/ | ||
var slice = _require('sliced') | ||
var flatten = _require('array-flatten') | ||
/** | ||
* This function lets us create virtual nodes using a simple | ||
* syntax. It is compatible with JSX transforms so you can use | ||
* JSX to write nodes that will compile to this function. | ||
* | ||
* let node = element('div', { id: 'foo' }, [ | ||
* element('a', { href: 'http://google.com' }, 'Google') | ||
* ]) | ||
* | ||
* You can leave out the attributes or the children if either | ||
* of them aren't needed and it will figure out what you're | ||
* trying to do. | ||
*/ | ||
module.exports = element | ||
/** | ||
* Create virtual trees of components. | ||
* | ||
* This creates the nicer API for the user. | ||
* It translates that friendly API into an actual tree of nodes. | ||
* | ||
* @param {*} type | ||
* @param {Object} attributes | ||
* @param {Array} children | ||
* @return {Object} | ||
* @api public | ||
*/ | ||
function element (type, attributes, children) { | ||
// Default to div with no args | ||
if (!type) { | ||
throw new TypeError('element() needs a type.') | ||
} | ||
// Skipped adding attributes and we're passing | ||
// in children instead. | ||
if (arguments.length === 2 && (typeof attributes === 'string' || Array.isArray(attributes))) { | ||
children = attributes | ||
attributes = {} | ||
} | ||
// Account for JSX putting the children as multiple arguments. | ||
// This is essentially just the ES6 rest param | ||
if (arguments.length > 2 && Array.isArray(arguments[2]) === false) { | ||
children = slice(arguments, 2) | ||
} | ||
children = children || [] | ||
attributes = attributes || {} | ||
// passing in a single child, you can skip | ||
// using the array | ||
if (!Array.isArray(children)) { | ||
children = [children] | ||
} | ||
// Flatten nested child arrays. This is how JSX compiles some nodes. | ||
children = flatten(children, 2) | ||
// if you pass in a function, it's a `Component` constructor. | ||
// otherwise it's an element. | ||
return { | ||
type: type, | ||
children: children, | ||
attributes: attributes | ||
} | ||
} | ||
},{"array-flatten":22,"sliced":23}],22:[function(_require,module,exports){ | ||
'use strict' | ||
/** | ||
* Expose `arrayFlatten`. | ||
*/ | ||
module.exports = arrayFlatten | ||
/** | ||
* Recursive flatten function with depth. | ||
* | ||
* @param {Array} array | ||
* @param {Array} result | ||
* @param {Number} depth | ||
* @return {Array} | ||
*/ | ||
function flattenWithDepth (array, result, depth) { | ||
for (var i = 0; i < array.length; i++) { | ||
var value = array[i] | ||
if (depth > 0 && Array.isArray(value)) { | ||
flattenWithDepth(value, result, depth - 1) | ||
} else { | ||
result.push(value) | ||
} | ||
} | ||
return result | ||
} | ||
/** | ||
* Recursive flatten function. Omitting depth is slightly faster. | ||
* | ||
* @param {Array} array | ||
* @param {Array} result | ||
* @return {Array} | ||
*/ | ||
function flattenForever (array, result) { | ||
for (var i = 0; i < array.length; i++) { | ||
var value = array[i] | ||
if (Array.isArray(value)) { | ||
flattenForever(value, result) | ||
} else { | ||
result.push(value) | ||
} | ||
} | ||
return result | ||
} | ||
/** | ||
* Flatten an array, with the ability to define a depth. | ||
* | ||
* @param {Array} array | ||
* @param {Number} depth | ||
* @return {Array} | ||
*/ | ||
function arrayFlatten (array, depth) { | ||
if (depth == null) { | ||
return flattenForever(array, []) | ||
} | ||
return flattenWithDepth(array, [], depth) | ||
} | ||
},{}],23:[function(_require,module,exports){ | ||
module.exports = exports = _require('./lib/sliced'); | ||
},{"./lib/sliced":24}],24:[function(_require,module,exports){ | ||
/** | ||
* An Array.prototype.slice.call(arguments) alternative | ||
* | ||
* @param {Object} args something with a length | ||
* @param {Number} slice | ||
* @param {Number} sliceEnd | ||
* @api public | ||
*/ | ||
module.exports = function (args, slice, sliceEnd) { | ||
var ret = []; | ||
var len = args.length; | ||
if (0 === len) return ret; | ||
var start = slice < 0 | ||
? Math.max(0, slice + len) | ||
: slice || 0; | ||
if (sliceEnd !== undefined) { | ||
len = sliceEnd < 0 | ||
? sliceEnd + len | ||
: sliceEnd | ||
} | ||
while (len-- > start) { | ||
ret[len - start] = args[len]; | ||
} | ||
return ret; | ||
} | ||
},{}]},{},[1])(1) | ||
}); |
{ | ||
"name": "magic-virtual-element", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"repository": "dekujs/magic-virtual-element", | ||
@@ -11,2 +11,3 @@ "description": "Build virtual tree elements with magic attributes", | ||
"browserify": "^11.0.1", | ||
"duoify": "^1.0.0", | ||
"hihat": "^2.4.0", | ||
@@ -26,5 +27,5 @@ "snazzy": "^1.0.1", | ||
"scripts": { | ||
"build": "mkdir -p build && browserify -s magic-virtual-element -e index.js | bfc > build/magic-virtual-element.js", | ||
"build": "mkdir -p build && browserify -s magic-virtual-element -e index.js -t duoify > build/magic-virtual-element.js", | ||
"test": "standard index.js && hihat test/index.js -- --debug -t babelify -p tap-dev-tool" | ||
} | ||
} |
@@ -1,4 +0,2 @@ | ||
/** | ||
* @jsx element | ||
*/ | ||
/** @jsx element */ | ||
@@ -38,8 +36,11 @@ var test = require('tape') | ||
test.only('jsx compatiblity', ({equal, end}) => { | ||
var child1 = element('div') | ||
var child2 = element('div') | ||
var node = element('div', null, child1, child2) | ||
test('jsx compatiblity', ({equal, end}) => { | ||
var node = ( | ||
<div> | ||
<span/> | ||
<span/> | ||
</div> | ||
) | ||
equal(node.children.length,2, 'children are spread') | ||
end() | ||
}) |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
4380
9
89
3
1