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

tusk

Package Overview
Dependencies
Maintainers
1
Versions
97
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tusk - npm Package Compare versions

Comparing version 0.3.6 to 0.3.7

4

lib/constants.js

@@ -1,2 +0,2 @@

/** tusk v0.3.6 https://www.npmjs.com/package/tusk */
/** tusk v0.3.7 https://www.npmjs.com/package/tusk */
module.exports = {

@@ -10,3 +10,3 @@ NODE: "__node__",

SELF_CLOSING: ["area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"],
EVENTS: ["blur", "change", "click", "contextmenu", "copy", "cut", "dblclick", "drag", "dragend", "dragenter", "dragexit", "dragleave", "dragover", "dragstart", "drop", "focus", "input", "keydown", "keypress", "keyup", "mousedown", "mouseenter", "mouseleave", "mousemove", "mouseout", "mouseover", "mouseup", "paste", "scroll", "submit", "touchcancel", "touchend", "touchmove", "touchstart", "wheel"]
EVENTS: ["animationend", "animationiteration", "animationstart", "beforeunload", "blur", "canplay", "canplaythrough", "change", "click", "contextmenu", "copy", "cut", "dblclick", "DOMContentLoaded", "drag", "dragend", "dragenter", "dragexit", "dragleave", "dragover", "dragstart", "drop", "durationchange", "emptied", "ended", "focus", "fullscreenchange", "input", "keydown", "keypress", "keyup", "load", "mousedown", "mouseenter", "mouseleave", "mousemove", "mouseout", "mouseover", "mouseup", "paste", "pause", "play", "playing", "reset", "scroll", "seeked", "seeking", "select", "submit", "suspend", "timeupdate", "touchcancel", "touchend", "touchmove", "touchstart", "transitionend", "visibilitychange", "volumechange", "waiting", "wheel"]
};

@@ -1,2 +0,2 @@

/** tusk v0.3.6 https://www.npmjs.com/package/tusk */
/** tusk v0.3.7 https://www.npmjs.com/package/tusk */
var EVENTS, NODE, onEvent, ref;

@@ -24,3 +24,3 @@

}
if (e.cancelBubble) {
if (e.cancelBubble || !e.bubbles) {
break;

@@ -27,0 +27,0 @@ }

@@ -1,2 +0,2 @@

/** tusk v0.3.6 https://www.npmjs.com/package/tusk */
/** tusk v0.3.7 https://www.npmjs.com/package/tusk */
var NODE, Node, flattenInto, getDiff, ref, renderContext, tusk;

@@ -3,0 +3,0 @@

@@ -1,6 +0,4 @@

/** tusk v0.3.6 https://www.npmjs.com/package/tusk */
var NODE, createNode, flattenInto;
/** tusk v0.3.7 https://www.npmjs.com/package/tusk */
var flattenInto;
NODE = require("./constants").NODE;
module.exports = {

@@ -62,30 +60,2 @@

/*
* Utility to extract out or create an elem from an existing node.
*
* @param {Virtual} node
*/
createNode: createNode = function(node) {
var elem;
elem = node._elem;
elem = (!elem ? node.create() : document.documentElement.contains(elem) ? elem.cloneNode(true) : elem);
elem[NODE] = node;
node._elem = elem;
return elem;
},
/*
* Utility to replace one node with another.
*
* @param {HTMLEntity} elem
* @param {Object} prev
* @param {Object} next
* @api private
*/
replaceNode: function(arg, next) {
var _elem;
_elem = arg._elem;
_elem.parentNode.replaceChild(createNode(next), _elem);
},
/*
* Utility that will update or set a given virtual nodes attributes.

@@ -131,3 +101,3 @@ * @param {HTMLEntity} elem

} else {
createNode(child);
child.create();
}

@@ -134,0 +104,0 @@ elem.insertBefore(child._elem, elem.childNodes[child.index]);

@@ -1,3 +0,3 @@

/** tusk v0.3.6 https://www.npmjs.com/package/tusk */
var NAMESPACES, NODE, Node, SELF_CLOSING, Text, escapeHTML, normalizeChildren, ref, ref1, replaceNode, setAttrs, setChildren,
/** tusk v0.3.7 https://www.npmjs.com/package/tusk */
var NAMESPACES, NODE, Node, SELF_CLOSING, Text, escapeHTML, normalizeChildren, ref, ref1, setAttrs, setChildren,
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };

@@ -7,3 +7,3 @@

ref = require("../util"), escapeHTML = ref.escapeHTML, replaceNode = ref.replaceNode, setAttrs = ref.setAttrs, setChildren = ref.setChildren;
ref = require("../util"), escapeHTML = ref.escapeHTML, setAttrs = ref.setAttrs, setChildren = ref.setChildren;

@@ -112,2 +112,5 @@ ref1 = require("../constants"), SELF_CLOSING = ref1.SELF_CLOSING, NODE = ref1.NODE, NAMESPACES = ref1.NAMESPACES;

var elem;
if (this._elem) {
return this._elem;
}
this._elem = elem = document.createElementNS(this.namespaceURI || NAMESPACES.HTML, this.type);

@@ -134,5 +137,8 @@ elem[NODE] = this;

Node.prototype.update = function(updated) {
if (this === updated) {
return this;
}
if (this.type !== updated.type) {
replaceNode(this, updated);
} else if (this !== updated) {
this._elem.parentNode.replaceChild(updated.create(), this._elem);
} else {
this._elem[NODE] = updated;

@@ -139,0 +145,0 @@ updated._elem = this._elem;

@@ -1,5 +0,5 @@

/** tusk v0.3.6 https://www.npmjs.com/package/tusk */
var Text, escapeHTML, ref, replaceNode;
/** tusk v0.3.7 https://www.npmjs.com/package/tusk */
var Text, escapeHTML;
ref = require("../util"), escapeHTML = ref.escapeHTML, replaceNode = ref.replaceNode;
escapeHTML = require("../util").escapeHTML;

@@ -48,2 +48,5 @@

Text.prototype.create = function() {
if (this._elem) {
return this._elem;
}
return this._elem = document.createTextNode(this.value);

@@ -62,7 +65,12 @@ };

Text.prototype.update = function(updated) {
if (updated.constructor !== Text) {
replaceNode(this, updated);
} else if (updated.value !== this.value) {
this._elem.nodeValue = updated.value;
if (this === updated) {
return this;
}
if (updated.constructor === Text) {
if (this.value !== updated.value) {
this._elem.nodeValue = updated.value;
}
} else {
this._elem.parentNode.replaceChild(updated.create(), this._elem);
}
updated._elem = this._elem;

@@ -69,0 +77,0 @@ return updated;

{
"name": "tusk",
"version": "0.3.6",
"version": "0.3.7",
"description": "A slim virtual dom implementation for immutable structures.",

@@ -5,0 +5,0 @@ "author": "Dylan Piercey <pierceydylan@gmail.com>",

@@ -50,13 +50,11 @@ # TUSK

function render () {
tusk.render(document.body,
<MyCounter message="Times clicked" cursor={ struct.cursor() }/>
)
}
// Initial render
render()
render();
// We can use the render function to re-render when the state changes.
struct.on("next-animation-frame", render)
struct.on("next-animation-frame", function render () {
tusk.render(document.body,
<MyCounter message="Times clicked" cursor={ struct.cursor() }/>
);
});

@@ -82,3 +80,5 @@ // We can also render into a string (Usually for the server).

function MyComponent (props, children, context) {
<div>External data: { context }</div>
return (
<div>External data: { context }</div>
);
}

@@ -117,6 +117,4 @@

let _ = require("lodash");
let i = 0;
let MyDiv = _.memoize(function () {
console.log(++i);
return (

@@ -128,12 +126,12 @@ <div>Hello World</div>

// creates and renders myDiv.
tusk.render(document.getElementById("component1"), <MyDiv/>);
i; // -> 1
tusk.render(document.body, <MyDiv/>);
// noop.
tusk.render(document.getElementById("component1"), <MyDiv/>);
i; // -> 1
tusk.render(document.body, <MyDiv/>);
// Uses #cloneNode on the previously rendered element. (Much faster than creating it).
tusk.render(document.getElementById("component2"), <MyDiv/>);
i; // -> 1
// render something entirely different.
tusk.render(document.body, <MyOtherDiv/>);
// switch back - reuses existing "MyDiv" dom. (Extremely fast).
tusk.render(document.body, <MyDiv/>);
```

@@ -140,0 +138,0 @@

Sorry, the diff of this file is not supported yet

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