Browse files

implemented remove-event-listener

  • Loading branch information...
1 parent c92c9f7 commit 375831d0232c307a8730097996060846f9f27663 @Raynos committed Apr 20, 2014
Showing with 21 additions and 0 deletions.
  1. +2 −0 dom-element.js
  2. +19 −0 event/remove-event-listener.js
View
2 dom-element.js
@@ -1,5 +1,6 @@
var dispatchEvent = require("./event/dispatch-event.js")
var addEventListener = require("./event/add-event-listener.js")
+var removeEventListener require("./event/remove-event-listener.js")
var serializeElement = require("./serialize.js")
var htmlns = "http://www.w3.org/1999/xhtml"
@@ -87,6 +88,7 @@ DOMElement.prototype.insertBefore =
return elem
}
+DOMElement.prototype.removeEventListener = removeEventListener
DOMElement.prototype.addEventListener = addEventListener
DOMElement.prototype.dispatchEvent = dispatchEvent
View
19 event/remove-event-listener.js
@@ -0,0 +1,19 @@
+module.exports = removeEventListener
+
+function removeEventListener(type, listener) {
+ var elem = this
+
+ if (!elem.listeners) {
+ return
+ }
+
+ if (!elem.listeners[type]) {
+ return
+ }
+
+ var list = elem.listeners[type]
+ var index = list.indexOf(listener)
+ if (index !== -1) {
+ list.splice(index, 1)
+ }
+}

0 comments on commit 375831d

Please sign in to comment.