Skip to content

Commit

Permalink
Fix firing the change event on SELECT tags when using jQuery.
Browse files Browse the repository at this point in the history
  • Loading branch information
djanowski committed Jan 28, 2011
1 parent 719fd7d commit 42f9edd
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
42 changes: 42 additions & 0 deletions spec/js-libs-compat.coffee
@@ -0,0 +1,42 @@
require "./helpers"
{ vows: vows, assert: assert, zombie: zombie, brains: brains } = require("vows")
jsdom = require("jsdom")

brains.get "/jquery", (req, res)-> res.send """
<html>
<head>
<title>jQuery</title>
<script src="/jquery.js"></script>
</head>
<body>
<select>
<option>None</option>
<option value="1">One</option>
</select>
<span id="option"></span>
</body>
<script>
$(function() {
$("select").bind("change", function() {
$("#option").text(this.value);
});
});
</script>
</html>
"""

vows.describe("Compatibility with JavaScript libraries").addBatch(
"jQuery":
zombie.wants "http://localhost:3003/jquery"
"selecting an option in a select element":
topic: (browser)->
browser.select "select", "1"
@callback null, browser
"should fire the change event": (browser)-> assert.equal browser.text("#option"), "1"


).export(module)
2 changes: 2 additions & 0 deletions src/zombie/browser.coffee
Expand Up @@ -491,7 +491,9 @@ class Browser extends require("events").EventEmitter
this.selectOption = (option)->
if(option && !option.selected)
select = @xpath("./ancestor::select", option).value[0]
@fire "beforeactivate", select
option.selected = true
@fire "beforedeactivate", select
@fire "change", select
return this

Expand Down

0 comments on commit 42f9edd

Please sign in to comment.