Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
patriksimek committed Oct 28, 2016
1 parent 6fa4114 commit 7dd7a0e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
"jquery",
"browser"
],
"version": "0.2.1",
"version": "0.2.2",
"main": "lib/sim.js",
"repository": {
"type": "git",
"url": "https://github.com/integromat/simdom"
},
"license": "MIT",
"dependencies": {
"jsdom": "^7.0.2"
"jsdom": "^9.8.3"
},
"devDependencies": {
"coffee-script": "^1.9.3",
Expand Down
10 changes: 10 additions & 0 deletions src/sim.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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 '*'
Expand Down Expand Up @@ -1085,6 +1089,7 @@ do (window = window ? null) ->
selector = undefined

fn = handler
events ?= Object.keys(@__handlers).join ' '

for event in events.split ' '
if FF
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
8 changes: 8 additions & 0 deletions test/test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7dd7a0e

Please sign in to comment.