Comparing version 4.3.2 to 4.4.0
14
index.js
var document = require('global/document') | ||
var hyperx = require('hyperx') | ||
var onload = require('on-load') | ||
@@ -56,2 +57,15 @@ var SVGNS = 'http://www.w3.org/2000/svg' | ||
// If adding onload events | ||
if (props.onload || props.onunload) { | ||
var load = props.onload | ||
var unload = props.onunload | ||
onload(el, function bel_onload () { | ||
load(el) | ||
}, function bel_onunload () { | ||
unload(el) | ||
}) | ||
delete props.onload | ||
delete props.onunload | ||
} | ||
// Create the properties | ||
@@ -58,0 +72,0 @@ for (var p in props) { |
{ | ||
"name": "bel", | ||
"version": "4.3.2", | ||
"version": "4.4.0", | ||
"description": "A simple extension to native elements", | ||
@@ -32,3 +32,4 @@ "main": "index.js", | ||
"global": "^4.3.0", | ||
"hyperx": "^2.0.2" | ||
"hyperx": "^2.0.2", | ||
"on-load": "^3.0.0" | ||
}, | ||
@@ -40,6 +41,6 @@ "devDependencies": { | ||
"standard": "^6.0.7", | ||
"tape": "^4.5.0", | ||
"tape": "^4.6.0", | ||
"testron": "^1.2.0", | ||
"wzrd": "^1.3.1" | ||
"wzrd": "^1.4.0" | ||
} | ||
} |
@@ -99,2 +99,20 @@ # [bel](https://en.wikipedia.org/wiki/Bel_(mythology)) | ||
### lifecycle events | ||
Use the `onload` and `onunload` properties to call a function when the element | ||
is inserted and removed from the DOM respectively. | ||
```js | ||
var bel = require('bel') | ||
var modal = bel`<div onload=${function (element) { | ||
console.log('Hello DOM!') | ||
}} onunload=${function (element) { | ||
console.log('Goodbye DOM!') | ||
}}>hello!</div>` | ||
document.body.appendChild(modal) | ||
document.body.removeChild(modal) | ||
``` | ||
### use with/without [hyperx](https://www.npmjs.com/package/hyperx) | ||
@@ -101,0 +119,0 @@ |
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
9205
124
158
3
+ Addedon-load@^3.0.0
+ Addednanoassert@1.1.0(transitive)
+ Addedon-load@3.4.1(transitive)