Created
May 11, 2012 16:14
-
-
Save snit-ram/2660714 to your computer and use it in GitHub Desktop.
Workaround to binder tests on mojito or nodejs-yui3
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
/* | |
* This file allows you to write binder tests using node.one(selector) in your | |
* mojito binder tests. simple add 'nodefix' to your "requires" on bindertests | |
* then use it like this: | |
* | |
* var node = Y.NodeFix.create('<div><p>sample child<p></div>') | |
* binder.bind(node); | |
* | |
* Then all the usage of node.one and node.all inside the binder will work as | |
* expected | |
*/ | |
YUI.add('nodefix', function (Y) { | |
'use strict'; | |
var jsdom; | |
Y.NodeFix = { | |
create: function (arg) { | |
jsdom = jsdom || require('jsdom'); | |
var doc = jsdom.jsdom(arg, null, { | |
features: { | |
QuerySelector: true | |
} | |
}), | |
node = Y.one(doc); | |
return node; | |
} | |
}; | |
}, '0.0.1', { | |
requires: ['node'] | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment