Project

General

Profile

Actions

Support #3002

open

Replacing jQuery with Cash

Added by Gregory Magarshak over 1 year ago.

Status:
New
Priority:
High
Assignee:
-
Category:
-
Start date:
09/04/2023
Due date:
01/23/2024 (about 16 months late)
% Done:

0%

Estimated time:

Description

https://github.com/fabiospampinato/cash

Basically you'd copy from here: https://github.com/fabiospampinato/cash/blob/master/dist/cash.min.js

And replace the jquery-3.2.1.min.js with this thig, in Q.json

BUT!

Although Cash does almost everything that jQuery does, it doesn't have pseudo-selectors like ":visible". This has been a feature request but Cash doesn't use $izzle library like jQuery does, to save space. So you would need to append this code, minified, to the file:


var _is = $.fn.is;
$.fn.is = function (s) {
    if (typeof s === 'string' || s instanceof String) {
        var i = s.indexOf(':visible');
        if (i >= 0) {
            var temp = (i > 0) ? this.filter(s.substring(0, i)) : this;
            return _is.apply(temp, [function () {
                return this.offsetWidth || this.offsetHeight;
            }]);
        }
    }
    return _is.apply(this, arguments);
};

['filter', 'next', 'nextAll', 'nextUntil', 
'prev', 'prevAll', 'prevUntil', 
'children', 'parents', 'parent']
.forEach(function (method) {
    var _m = $.fn[method];
    $.fn[method] = function (s) {
        if (typeof s === 'string' || s instanceof String) {
            var i = s.indexOf(':visible');
            if (i >= 0) {
                var c = _m.apply(this, [function () {
                    return this.offsetWidth || this.offsetHeight;
                }]);
                if (i > 0) {
                    c = c.filter(s.substring(0, i));
                }
                return c;
            }
        }
        return _m.apply(this, arguments);
    };
});

But even so, it doesn't support .animate() method and a few others. Luckily you can just change all those to Q.Animation.play()

No data to display

Actions

Also available in: Atom PDF