nanocomponent
Advanced tools
Comparing version 6.0.1 to 6.1.0
14
index.js
var document = require('global/document') | ||
var nanotiming = require('nanotiming') | ||
var morph = require('nanomorph') | ||
@@ -12,3 +13,3 @@ var onload = require('on-load') | ||
function Nanocomponent () { | ||
function Nanocomponent (name) { | ||
this._hasWindow = typeof window !== 'undefined' | ||
@@ -20,2 +21,3 @@ this._id = null // represents the id of the root node | ||
this._rootNodeName = null | ||
this._name = name || 'nanocomponent' | ||
@@ -36,7 +38,11 @@ this._handleLoad = this._handleLoad.bind(this) | ||
Nanocomponent.prototype.render = function () { | ||
var timing = nanotiming(this._name + '.render') | ||
var self = this | ||
var args = new Array(arguments.length) | ||
var el | ||
for (var i = 0; i < arguments.length; i++) args[i] = arguments[i] | ||
if (!this._hasWindow) { | ||
return this.createElement.apply(this, args) | ||
el = this.createElement.apply(this, args) | ||
timing() | ||
return el | ||
} else if (this.element) { | ||
@@ -49,6 +55,7 @@ var shouldUpdate = this.update.apply(this, args) | ||
if (!this._proxy) { this._proxy = this._createProxy() } | ||
timing() | ||
return this._proxy | ||
} else { | ||
this._reset() | ||
var el = this._handleRender(args) | ||
el = this._handleRender(args) | ||
if (this.beforerender) this.beforerender(el) | ||
@@ -58,2 +65,3 @@ if (this.load || this.unload) { | ||
} | ||
timing() | ||
return el | ||
@@ -60,0 +68,0 @@ } |
{ | ||
"name": "nanocomponent", | ||
"version": "6.0.1", | ||
"version": "6.1.0", | ||
"description": "Native DOM components that pair nicely with DOM diffing algorithms", | ||
@@ -42,2 +42,3 @@ "main": "index.js", | ||
"nanomorph": "^5.1.2", | ||
"nanotiming": "^6.1.3", | ||
"on-load": "^3.2.0" | ||
@@ -44,0 +45,0 @@ }, |
@@ -288,5 +288,5 @@ # nanocomponent [![stability][0]][1] | ||
## API | ||
### `component = Nanocomponent()` | ||
### `component = Nanocomponent([name])` | ||
Create a new Nanocomponent instance. Additional methods can be set on the | ||
prototype. | ||
prototype. Takes an optional name which is used when emitting timings. | ||
@@ -293,0 +293,0 @@ ### `component.render([arguments…])` |
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
36630
445
4
+ Addednanotiming@^6.1.3
+ Addednanotiming@6.1.5(transitive)