Created
January 29, 2014 14:50
-
-
Save bustardcelly/8689593 to your computer and use it in GitHub Desktop.
zombiejs patch for non-trapping of link event to allow for bubble up when using SAP libraries.
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
/** | |
* We are using page.js for client routing. | |
* We are using zombie.js as a headless browser during testing. | |
* | |
* zombie.js traps the click event of an A element and prevents it from bubbling up to the window. | |
* page.js listens for 'click' on window to determine location routing. | |
* | |
* As such, they conflict and setup for changing location within a SAP within a test will return a 404. | |
* Load this in as a patch for zombie within a feature module that requires a change to the location. | |
*/ | |
var HTML = require(process.cwd() + "/node_modules/zombie/node_modules/jsdom").dom.level3.html; | |
HTML.HTMLAnchorElement.prototype._eventDefaults = { | |
click: function(event) { | |
var anchor, browser, window; | |
anchor = event.target; | |
if (!anchor.href) { | |
return; | |
} | |
window = anchor.ownerDocument.window; | |
event.which = 1; | |
window.dispatchEvent(event); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment