nanocomponent
Advanced tools
Comparing version 4.0.0 to 4.0.1
11
index.js
var onload = require('on-load') | ||
var assert = require('assert') | ||
var KEY = 'ncid-' + (new Date() % 9e6).toString(36) | ||
var INDEX = 0 | ||
module.exports = Nanocomponent | ||
@@ -8,2 +11,3 @@ | ||
this._hasWindow = typeof window !== 'undefined' | ||
this._ID = KEY + '-' + INDEX++ | ||
this._placeholder = null | ||
@@ -29,2 +33,8 @@ this._onload = onload | ||
this._element = this._render.apply(this, args) | ||
// Get ID - needed for nanomorph child element reordering | ||
var id = this._element.getAttribute('id') | ||
if (!id) this._element.setAttribute('id', this._ID) | ||
else this._ID = id | ||
this._onload(this._element, function () { | ||
@@ -59,2 +69,3 @@ self._loaded = true | ||
el.setAttribute('data-nanocomponent', '') | ||
el.setAttribute('id', this._ID) | ||
var self = this | ||
@@ -61,0 +72,0 @@ el.isSameNode = function (el) { |
{ | ||
"name": "nanocomponent", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "Create performant HTML elements", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -22,7 +22,13 @@ # nanocomponent [![stability][0]][1] | ||
this._color = color | ||
return html` | ||
<button style="background-color: ${color}"> | ||
Click Me | ||
</button> | ||
` | ||
if (!this._element) { | ||
// initial render | ||
return html` | ||
<button style="background-color: ${color}"> | ||
Click Me | ||
</button> | ||
` | ||
} else { | ||
// mutate this._element | ||
this._element.style.backgroundColor = color | ||
} | ||
} | ||
@@ -80,3 +86,4 @@ | ||
Inheritable Nanocomponent prototype. Should be inherited from using | ||
`Nanococomponent.call(this)` and `prototype = Object.create(Nanocomponent)`. | ||
`Nanococomponent.call(this)` and `prototype = | ||
Object.create(Nanocomponent.prototype)`. | ||
@@ -83,0 +90,0 @@ Internal properties are: |
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
27278
756
164