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

vdom-virtualize

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vdom-virtualize - npm Package Compare versions

Comparing version 0.0.0 to 0.0.1

build.js

217

index.js

@@ -0,13 +1,34 @@

/*!
* vdom-virtualize
* Copyright 2014 by Marcel Klehr <mklehr@gmx.net>
*
* (MIT LICENSE)
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
var VNode = require("virtual-dom/vtree/vnode")
, VText = require("virtual-dom/vtree/vtext")
exports.virtualize =
exports.createVTree = createVNode
module.exports = createVNode
function createVNode(domNode, key) {
key = key || null // XXX: Leave out `key` for now... merely used for (re-)ordering
if(domNode.nodeType == 1) return createFromElement(domNode, key)
if(domNode.nodeType == 3) return createFromTextNode(domNode, key)
return

@@ -17,3 +38,3 @@ }

function createFromTextNode(tNode) {
return new VText(tNode.toString()) // XXX: I'm not sure if toString exists here.
return new VText(tNode.nodeValue)
}

@@ -24,8 +45,8 @@

var tagName = el.tagName
, namespace = el.namespaceURI
, namespace = el.namespaceURI == 'http://www.w3.org/1999/xhtml'? null : el.namespaceURI
, properties = getElementProperties(el)
, children = []
for (var i = 0; i < el.chilNodes.length; i++) {
children.push(createVNode(el.chilNodes[i]/*, i*/))
for (var i = 0; i < el.childNodes.length; i++) {
children.push(createVNode(el.childNodes[i]/*, i*/))
}

@@ -43,6 +64,14 @@

if("stlye" == propName) {
// Special case: style
// .style is a DOMStyleDeclaration, thus we need to iterate over all
// rules to create a hash of applied css properties.
//
// You can directly set a specific .style[prop] = value so patching with vdom
// is possible.
if("style" == propName) {
var css = {}
, styleProp
for(var i=0; i<el.style; i++) {
css[el.style[i]] = el.style.getPropertyValue(el.style[i]) // XXX: add support for "!important" via getPropertyPriority()!
styleProp = el.style[i]
css[styleProp] = el.style.getPropertyValue(styleProp) // XXX: add support for "!important" via getPropertyPriority()!
}

@@ -54,2 +83,10 @@

// Special case: dataset
// we can iterate over .dataset with a simple for..in loop.
// The all-time foo with data-* attribs is the dash-snake to camelCase
// conversion.
// However, I'm not sure if this is compatible with h()
//
// .dataset properties are directly accessible as transparent getters/setters, so
// patching with vdom is possible.
if("dataset" == propName) {

@@ -64,6 +101,15 @@ var data = {}

}
// Special case: attributes
// some properties are only accessible via .attributes, so
// that's what we'd do, if vdom-create-element could handle this.
if("attributes" == propName) return
// default: just copy the property
obj[propName] = el[propName]
return
})
return obj
}

@@ -73,21 +119,138 @@

* DOMNode property white list
* Taken from https://github.com/Raynos/react/blob/dom-property-config/src/browser/ui/dom/DefaultDOMPropertyConfig.js
*/
var props =
exports.properties = [
"id"
, "className"
, "accessKey"
, "contentEditable"
, "dir"
, "lang"
, "spellcheck"
, "style"
, "dataset"
, "title"
, "src"
, "border"
, "alt"
, "checked"
, "value"
, "selected"]
module.exports.properties = [
"accept"
,"accessKey"
,"action"
,"alt"
,"async"
,"autoComplete"
,"autoPlay"
,"cellPadding"
,"cellSpacing"
,"checked"
,"className"
,"colSpan"
,"content"
,"contentEditable"
,"controls"
,"crossOrigin"
,"data"
,"defer"
,"dir"
,"download"
,"draggable"
,"encType"
,"formNoValidate"
,"href"
,"hrefLang"
,"htmlFor"
,"httpEquiv"
,"icon"
,"id"
,"label"
,"lang"
,"list"
,"loop"
,"max"
,"mediaGroup"
,"method"
,"min"
,"multiple"
,"muted"
,"name"
,"noValidate"
,"pattern"
,"placeholder"
,"poster"
,"preload"
,"radioGroup"
,"readOnly"
,"rel"
,"required"
,"rowSpan"
,"sandbox"
,"scope"
,"scrollLeft"
,"scrolling"
,"scrollTop"
,"selected"
,"span"
,"spellCheck"
,"src"
,"srcDoc"
,"srcSet"
,"start"
,"step"
,"style"
,"tabIndex"
,"target"
,"title"
,"type"
,"value"
// Non-standard Properties
,"autoCapitalize"
,"autoCorrect"
,"property"
, "attributes"
]
var attrs =
module.exports.attrs = [
"allowFullScreen"
,"allowTransparency"
,"charSet"
,"cols"
,"contextMenu"
,"dateTime"
,"disabled"
,"form"
,"frameBorder"
,"height"
,"hidden"
,"maxLength"
,"role"
,"rows"
,"seamless"
,"size"
,"width"
,"wmode"
// SVG Properties
,"cx"
,"cy"
,"d"
,"dx"
,"dy"
,"fill"
,"fx"
,"fy"
,"gradientTransform"
,"gradientUnits"
,"offset"
,"points"
,"r"
,"rx"
,"ry"
,"spreadMethod"
,"stopColor"
,"stopOpacity"
,"stroke"
,"strokeLinecap"
,"strokeWidth"
,"textAnchor"
,"transform"
,"version"
,"viewBox"
,"x1"
,"x2"
,"x"
,"y1"
,"y2"
,"y"
]

2

package.json
{
"name": "vdom-virtualize",
"version": "0.0.0",
"version": "0.0.1",
"description": "Virtulize any DOM node and turn it into a virtual-dom node.",

@@ -5,0 +5,0 @@ "main": "index.js",

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