nanocomponent
Advanced tools
Comparing version 6.4.1 to 6.4.2
23
index.js
@@ -5,2 +5,4 @@ var document = require('global/document') | ||
var onload = require('on-load') | ||
var OL_KEY_ID = onload.KEY_ID | ||
var OL_ATTR_ID = onload.KEY_ATTR | ||
var assert = require('assert') | ||
@@ -18,2 +20,3 @@ | ||
this._ncID = null // internal nanocomponent id | ||
this._olID = null | ||
this._proxy = null | ||
@@ -51,7 +54,8 @@ this._loaded = false // Used to debounce on-load when child-reordering | ||
} else if (this.element) { | ||
el = this.element // retain reference, as the ID might change on render | ||
var shouldUpdate = this._rerender || this.update.apply(this, args) | ||
if (this._rerender) this._render = false | ||
if (shouldUpdate) { | ||
morph(this.element, this._handleRender(args)) | ||
if (this.afterupdate) this.afterupdate(this.element) | ||
morph(el, this._handleRender(args)) | ||
if (this.afterupdate) this.afterupdate(el) | ||
} | ||
@@ -66,3 +70,4 @@ if (!this._proxy) { this._proxy = this._createProxy() } | ||
if (this.load || this.unload || this.afterreorder) { | ||
onload(el, self._handleLoad, self._handleUnload, self) | ||
onload(el, self._handleLoad, self._handleUnload, self._ncID) | ||
this._olID = el.dataset[OL_KEY_ID] | ||
} | ||
@@ -103,2 +108,3 @@ timing() | ||
this._ncID = makeID() | ||
this._olID = null | ||
this._id = null | ||
@@ -111,2 +117,3 @@ this._proxy = null | ||
node.setAttribute('data-nanocomponent', this._ncID) | ||
if (this._olID) node.setAttribute(OL_ATTR_ID, this._olID) | ||
return node | ||
@@ -118,2 +125,4 @@ } | ||
else node.id = this._id = this._ncID | ||
// Update proxy node ID if it changed | ||
if (this._proxy && this._proxy.id !== this._id) this._proxy.id = this._id | ||
return node | ||
@@ -123,16 +132,14 @@ } | ||
Nanocomponent.prototype._handleLoad = function (el) { | ||
var self = this | ||
if (this._loaded) { | ||
if (this.afterreorder) window.requestAnimationFrame(function () { self.afterreorder(el) }) | ||
if (this.afterreorder) this.afterreorder(el) | ||
return // Debounce child-reorders | ||
} | ||
this._loaded = true | ||
if (this.load) window.requestAnimationFrame(function () { self.load(el) }) | ||
if (this.load) this.load(el) | ||
} | ||
Nanocomponent.prototype._handleUnload = function (el) { | ||
var self = this | ||
if (this.element) return // Debounce child-reorders | ||
this._loaded = false | ||
if (this.unload) window.requestAnimationFrame(function () { self.unload(el) }) | ||
if (this.unload) this.unload(el) | ||
} | ||
@@ -139,0 +146,0 @@ |
{ | ||
"name": "nanocomponent", | ||
"version": "6.4.1", | ||
"version": "6.4.2", | ||
"description": "Native DOM components that pair nicely with DOM diffing algorithms", | ||
@@ -47,3 +47,3 @@ "main": "index.js", | ||
"nanotiming": "^6.1.3", | ||
"on-load": "^3.2.3" | ||
"on-load": "^3.3.1" | ||
}, | ||
@@ -50,0 +50,0 @@ "devDependencies": { |
@@ -131,4 +131,4 @@ var test = require('tape') | ||
var comp = new LifeCycleComp() | ||
comp.bus.on('load', onLoad) | ||
comp.bus.on('unload', onUnload) | ||
comp.bus.on('load', () => window.requestAnimationFrame(onLoad)) | ||
comp.bus.on('unload', () => window.requestAnimationFrame(onUnload)) | ||
@@ -135,0 +135,0 @@ t.deepEqual(comp.testState, { |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
234284
469
1
Updatedon-load@^3.3.1