vdom-virtualize
Advanced tools
Comparing version 0.0.13 to 1.0.0
31
index.js
@@ -26,2 +26,3 @@ /*! | ||
, VText = require("virtual-dom/vnode/vtext") | ||
, VComment = require("./vcomment") | ||
@@ -35,2 +36,3 @@ module.exports = createVNode | ||
if(domNode.nodeType == 3) return createFromTextNode(domNode, key) | ||
if(domNode.nodeType == 8) return createFromCommentNode(domNode, key) | ||
return | ||
@@ -40,6 +42,22 @@ } | ||
createVNode.fromHTML = function(html, key) { | ||
var domNode = document.createElement('div'); // create container | ||
domNode.innerHTML = html; // browser parses HTML into DOM tree | ||
var child = domNode.children.length ? domNode.children[0] : domNode.firstChild; | ||
return createVNode(child, key); | ||
var rootNode = null; | ||
try { | ||
// Everything except iOS 7 Safari, IE 8/9, Andriod Browser 4.1/4.3 | ||
var parser = new DOMParser(); | ||
var doc = parser.parseFromString(html, 'text/html'); | ||
rootNode = doc.documentElement; | ||
} catch(e) { | ||
// Old browsers | ||
var ifr = document.createElement('iframe'); | ||
ifr.setAttribute('data-content', html); | ||
ifr.src = 'javascript: window.frameElement.getAttribute("data-content");'; | ||
document.head.appendChild(ifr); | ||
rootNode = ifr.contentDocument.documentElement; | ||
setTimeout(function() { | ||
ifr.remove(); // Garbage collection | ||
}, 0); | ||
} | ||
return createVNode(rootNode, key); | ||
}; | ||
@@ -52,2 +70,7 @@ | ||
function createFromCommentNode(cNode) { | ||
return new VComment(cNode.nodeValue) | ||
} | ||
function createFromElement(el) { | ||
@@ -54,0 +77,0 @@ var tagName = el.tagName |
{ | ||
"name": "vdom-virtualize", | ||
"version": "0.0.13", | ||
"version": "1.0.0", | ||
"description": "Virtulize any DOM node and turn it into a virtual-dom node.", | ||
"main": "index.js", | ||
"dependencies": { | ||
"peerDependencies": { | ||
"virtual-dom": "2.0.1" | ||
@@ -8,0 +8,0 @@ }, |
# vdom-virtualize | ||
**New in v1.0:** vdom-virtualize now supports comments and does now use peerDependencies to depend on virtual-dom. | ||
## API | ||
@@ -4,0 +6,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
18
0
9525
295
- Removedvirtual-dom@2.0.1