Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove onload #69

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
var document = require('global/document')
var hyperx = require('hyperx')
var onload = require('on-load')

var SVGNS = 'http://www.w3.org/2000/svg'
var XLINKNS = 'http://www.w3.org/1999/xlink'
Expand Down Expand Up @@ -60,21 +59,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 @@ -29,8 +29,7 @@
"homepage": "https://github.com/shama/bel",
"dependencies": {
"global": "^4.3.0",
"hyperx": "^2.3.0",
"on-load": "^3.2.0"
"hyperx": "^2.3.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')
47 changes: 0 additions & 47 deletions test/onload.js

This file was deleted.