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

nanocomponent

Package Overview
Dependencies
Maintainers
22
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nanocomponent - npm Package Compare versions

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, {

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