Skip to content

Instantly share code, notes, and snippets.

@snit-ram
Created May 11, 2012 16:14
Show Gist options
  • Save snit-ram/2660714 to your computer and use it in GitHub Desktop.
Save snit-ram/2660714 to your computer and use it in GitHub Desktop.
Workaround to binder tests on mojito or nodejs-yui3
/*
* 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