JSFiddle - React, Tailwind, and code Playground
HTML
<p rel="summary">An overview of the state of the Universe.</p>
<p>Pandas are cool.</p>
JavaScript
$(function() {
//// how are plugins handled by sub()?
addPluginA($);
var $$ = $.sub();
addPluginB($$);
console.log(typeof $('body').pluginA); // function
console.log(typeof $$('body').pluginA); // function
console.log(typeof $('body').pluginB); // undefined
console.log(typeof $$('body').pluginB); // function
//// how are sizzle extensions handled by sub()?
addCustomSelector($$)
try {
$('p:summary').css('text-decoration', 'underline'); // errors
}
catch(e) { console.log('$ selector = '+e); }
try {
$$('p:summary').css('text-decoration', 'underline'); // errors
}
catch(e) { console.log('$$ selector = '+e); }
addCustomSelector($)
$('p:summary').css('text-decoration', 'underline'); // works
$$('p:summary').css('color', 'red'); // works
});
function addPluginA(jqRef) {
jqRef.fn.pluginA = function(){
return 'hello A';
};
}
function addPluginB(jqRef) {
jqRef.fn.pluginB = function(){
return 'hello B';
};
}
function addCustomSelector(jqRef) {
jqRef.expr[':']['summary'] = function(el) {
return jqRef(el).attr('rel') === 'summary';
}
}