diff --git a/package.json b/package.json index 5ea231d..ebcb1cc 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "jquery", "browser" ], - "version": "0.2.1", + "version": "0.2.2", "main": "lib/sim.js", "repository": { "type": "git", @@ -19,7 +19,7 @@ }, "license": "MIT", "dependencies": { - "jsdom": "^7.0.2" + "jsdom": "^9.8.3" }, "devDependencies": { "coffee-script": "^1.9.3", diff --git a/src/sim.coffee b/src/sim.coffee index ccb8e02..b960238 100644 --- a/src/sim.coffee +++ b/src/sim.coffee @@ -259,6 +259,10 @@ do (window = window ? null) -> if conditions.length is 0 return true + # text cant match any of following + if elm instanceof SIMText + return false + for condition in conditions if condition.tag? if condition.tag is '*' @@ -1085,6 +1089,7 @@ do (window = window ? null) -> selector = undefined fn = handler + events ?= Object.keys(@__handlers).join ' ' for event in events.split ' ' if FF @@ -1430,6 +1435,7 @@ do (window = window ? null) -> after: SIMElement::after appendTo: SIMElement::appendTo before: SIMElement::before + closest: -> null detach: SIMElement::detach hasClass: -> false prependTo: SIMElement::prependTo @@ -1446,9 +1452,11 @@ do (window = window ? null) -> text: SIMElement::text class SIMDocument extends SIMBase + closest: -> null emit: SIMElement::emit height: -> window.document.documentElement.offsetHeight inspect: -> "[SIMDocument]" + is: (selector) -> selector is 'document' on: SIMElement::on once: SIMElement::once off: SIMElement::off @@ -1457,9 +1465,11 @@ do (window = window ? null) -> width: -> window.document.documentElement.offsetWidth class SIMWindow extends SIMBase + closest: -> null emit: SIMElement::emit height: -> window.document.documentElement.clientHeight inspect: -> "[SIMWindow]" + is: -> false on: SIMElement::on once: SIMElement::once off: SIMElement::off diff --git a/test/test.coffee b/test/test.coffee index 9988220..32652e6 100644 --- a/test/test.coffee +++ b/test/test.coffee @@ -324,6 +324,14 @@ describe 'basic test suite', -> dom.emit 'resize' assert.strictEqual ticks, 1 + it.skip 'should handle events #9', -> + dom = sim.div -> + @on 'resize', -> throw new Error "..." + @on 'resize', -> throw new Error "..." + + dom.off() + dom.emit 'resize' + it 'should create a custom component #1', -> class SIMElementExtended extends sim.SIMElement sim.registerComponent 'custom-component', SIMElementExtended