Skip to content

Commit

Permalink
remove onload (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshuawuyts authored May 19, 2017
1 parent 9611b7f commit 3370966
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 87 deletions.
26 changes: 4 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,24 +96,6 @@ module.exports = function (bears) {
}
```

### 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)

`hyperx` is built into `bel` but there may be times when you wish to use your
Expand Down Expand Up @@ -160,13 +142,13 @@ bel sets attributes with `element.setAttribute()` and `element.setAttributeNS()`

## similar projects

* [vel](https://github.com/yoshuawuyts/vel)
* [vel](https://github.com/yoshuawuyts/vel)
minimal virtual-dom library
* [base-element](https://github.com/shama/base-element)
* [base-element](https://github.com/shama/base-element)
An element authoring library for creating standalone and performant elements
* [virtual-dom](https://github.com/Matt-Esch/virtual-dom)
* [virtual-dom](https://github.com/Matt-Esch/virtual-dom)
A Virtual DOM and diffing algorithm
* [hyperscript](https://github.com/dominictarr/hyperscript)
* [hyperscript](https://github.com/dominictarr/hyperscript)
Create HyperText with JavaScript.

# license
Expand Down
16 changes: 0 additions & 16 deletions browser.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
var hyperx = require('hyperx')
var onload = require('on-load')

var headRegex = /^\n[\s]+/
var tailRegex = /\n[\s]+$/
Expand Down Expand Up @@ -62,21 +61,6 @@ function belCreateElement (tag, props, children) {
el = document.createElement(tag)
}

// If adding onload events
if (props.onload || props.onunload) {
var load = props.onload || function () {}
var unload = props.onunload || function () {}
onload(el, function belOnload () {
load(el)
}, function belOnunload () {
unload(el)
},
// We have to use non-standard `caller` to find who invokes `belCreateElement`
belCreateElement.caller.caller.caller)
delete props.onload
delete props.onunload
}

// Create the properties
for (var p in props) {
if (props.hasOwnProperty(p)) {
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
"homepage": "https://github.com/shama/bel",
"dependencies": {
"hyperx": "^2.3.0",
"is-electron": "^2.0.0",
"on-load": "^3.2.0"
"is-electron": "^2.0.0"
},
"devDependencies": {
"browser-process-hrtime": "^0.1.2",
Expand Down
1 change: 0 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
require('./api.js')
require('./elements.js')
require('./onload.js')
46 changes: 0 additions & 46 deletions test/onload.js

This file was deleted.

0 comments on commit 3370966

Please sign in to comment.