var noop = function () {};

var zjquery = (function () {

var elems = {};
var exports = {};

function new_elem(selector) {
    var text = 'never-been-set';
    var value;
    var shown = false;
    var focused = false;
    var children = new Dict();
    var my_parent;
    var classes = new Dict();

    var self = {
        val: function () {
            if (arguments.length === 0) {
                return value || '';
            }
            value = arguments[0];
        },
        css: noop,
        data: noop,
        empty: noop,
        height: noop,
        removeAttr: noop,
        removeData: noop,
        trigger: noop,
        blur: function () {
            focused = false;
        },
        text: function (arg) {
            if (arg !== undefined) {
                text = arg;
            } else {
                return text;
            }
        },
        focus: function () {
            focused = true;
        },
        show: function () {
            shown = true;
        },
        hide: function () {
            shown = false;
        },
        addClass: function (class_name) {
            if (class_name === 'active') {
                shown = true;
            }
            classes.set(class_name, true);
        },
        removeClass: function (class_name) {
            if (class_name === 'status_classes') {
                return self;
            }
            if (class_name === 'active') {
                shown = false;
            }
            classes.del(class_name);
        },
        hasClass: function (class_name) {
            return classes.has(class_name);
        },
        debug: function () {
            return {
                value: value,
                shown: shown,
                selector: selector,
            };
        },
        visible: function () {
            return shown;
        },
        is_focused: function () {
            // is_focused is not a jQuery thing; this is
            // for our testing
            return focused;
        },
        find: function (child_selector) {
            var child = children.get(child_selector);
            if (child) {
                return child;
            }

            throw "Cannot find " + child_selector + " in " + selector;
        },
        add_child: function (child_selector, child_elem) {
            child_elem.set_parent(self);
            children.set(child_selector, child_elem);
        },
        set_parent: function (parent_elem) {
            my_parent = parent_elem;
        },
        parent: function () {
            return my_parent;
        },
    };
    return self;
}

function jquery_array(elem) {
    var result = [elem];

    for (var attr in elem) {
        if (Object.prototype.hasOwnProperty.call(elem, attr)) {
            result[attr] = elem[attr];
        }
    }

    return result;
}

exports.zjquery = function (arg) {
    if (typeof arg === "function") {
        // If somebody is passing us a function, we emulate
        // jQuery's behavior of running this function after
        // page load time.  But there are no pages to load,
        // so we just call it right away.
        arg();
        return;
    }

    var selector = arg;
    if (elems[selector] === undefined) {
        var elem = new_elem(selector);
        elems[selector] = elem;
    }
    return jquery_array(elems[selector]);
};

exports.zjquery.trim = function (s) { return s; };

exports.zjquery.state = function () {
    // useful for debugging
    var res =  _.map(elems, function (v) {
        return v.debug();
    });

    res = _.map(res, function (v) {
        return [v.selector, v.value, v.shown];
    });

    res.sort();

    return res;
};

exports.zjquery.Event = noop;

return exports;
}());
module.exports = zjquery;

@@ -112,24 +112,57 @@
 selector) %7B%0A
+    var html = 'never-been-set';%0A
     var text
@@ -724,32 +724,203 @@
 lse;%0A        %7D,%0A
+        html: function (arg) %7B%0A            if (arg !== undefined) %7B%0A                html = arg;%0A            %7D else %7B%0A                return html;%0A            %7D%0A        %7D,%0A
         text: fu
@@ -1319,95 +1319,8 @@
 ) %7B%0A
-            if (class_name === 'active') %7B%0A                shown = true;%0A            %7D%0A
     
@@ -1354,24 +1354,49 @@
 ame, true);%0A
+            return self;%0A
         %7D,%0A 
@@ -1443,190 +1443,8 @@
 ) %7B%0A
-            if (class_name === 'status_classes') %7B%0A                return self;%0A            %7D%0A            if (class_name === 'active') %7B%0A                shown = false;%0A            %7D%0A
     
@@ -1468,32 +1468,57 @@
 el(class_name);%0A
+            return self;%0A
         %7D,%0A     
@@ -2583,24 +2583,190 @@
 %0A        %7D,%0A
+        expectOne: function () %7B%0A            // silently do nothing%0A            return self;%0A        %7D,%0A        on: function () %7B%0A            return self;%0A        %7D,%0A
     %7D;%0A    r
@@ -3469,20 +3469,34 @@
 ctor%5D = 
+jquery_array(
 elem
+)
 ;%0A    %7D%0A
@@ -3506,29 +3506,101 @@
  return 
-jquery_array(
+elems%5Bselector%5D;%0A%7D;%0A%0Aexports.zjquery.stub_selector = function (selector, stub) %7B%0A    
 elems%5Bse
@@ -3606,17 +3606,23 @@
 elector%5D
-)
+ = stub
 ;%0A%7D;%0A%0Aex

Add features to zjquery.