-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from deepak1556/vdom_patch
using evstore for vdom compatibility
- Loading branch information
Showing
5 changed files
with
31 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
var DataSet = require("data-set") | ||
var EvStore = require("ev-store") | ||
|
||
module.exports = addEvent | ||
|
||
function addEvent(target, type, handler) { | ||
var ds = DataSet(target) | ||
var events = ds[type] | ||
var events = EvStore(target) | ||
var event = events[type] | ||
|
||
if (!events) { | ||
ds[type] = handler | ||
} else if (Array.isArray(events)) { | ||
if (events.indexOf(handler) === -1) { | ||
events.push(handler) | ||
if (!event) { | ||
events[type] = handler | ||
} else if (Array.isArray(event)) { | ||
if (event.indexOf(handler) === -1) { | ||
event.push(handler) | ||
} | ||
} else if (events !== handler) { | ||
ds[type] = [events, handler] | ||
} else if (event !== handler) { | ||
events[type] = [event, handler] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
var DataSet = require("data-set") | ||
var EvStore = require("ev-store") | ||
|
||
module.exports = removeEvent | ||
|
||
function removeEvent(target, type, handler) { | ||
var ds = DataSet(target) | ||
var events = ds[type] | ||
var events = EvStore(target) | ||
var event = events[type] | ||
|
||
if (!events) { | ||
if (!event) { | ||
return | ||
} else if (Array.isArray(events)) { | ||
var index = events.indexOf(handler) | ||
} else if (Array.isArray(event)) { | ||
var index = event.indexOf(handler) | ||
if (index !== -1) { | ||
events.splice(index, 1) | ||
event.splice(index, 1) | ||
} | ||
} else if (events === handler) { | ||
ds[type] = null | ||
} else if (event === handler) { | ||
events[type] = null | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters