2016-01-11 02:25:30 +01:00
|
|
|
(function (global, factory) {
|
|
|
|
if (typeof define === "function" && define.amd) {
|
|
|
|
define('ss.leaktools', ['jQuery'], factory);
|
|
|
|
} else if (typeof exports !== "undefined") {
|
|
|
|
factory(require('jQuery'));
|
|
|
|
} else {
|
|
|
|
var mod = {
|
|
|
|
exports: {}
|
|
|
|
};
|
|
|
|
factory(global.jQuery);
|
|
|
|
global.ssLeaktools = mod.exports;
|
|
|
|
}
|
|
|
|
})(this, function (_jQuery) {
|
2016-02-12 04:00:15 +01:00
|
|
|
'use strict';
|
|
|
|
|
2016-01-11 02:25:30 +01:00
|
|
|
var _jQuery2 = _interopRequireDefault(_jQuery);
|
|
|
|
|
|
|
|
function _interopRequireDefault(obj) {
|
|
|
|
return obj && obj.__esModule ? obj : {
|
|
|
|
default: obj
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
var getHTML = function getHTML(el) {
|
|
|
|
var clone = el.cloneNode(true);
|
2016-03-04 04:40:54 +01:00
|
|
|
|
2016-01-11 02:25:30 +01:00
|
|
|
var div = (0, _jQuery2.default)('<div></div>');
|
|
|
|
div.append(clone);
|
2016-03-04 04:40:54 +01:00
|
|
|
|
2016-01-11 02:25:30 +01:00
|
|
|
return div.html();
|
|
|
|
};
|
|
|
|
|
|
|
|
_jQuery2.default.leaktools = {
|
2016-03-04 04:40:54 +01:00
|
|
|
|
2016-01-11 02:25:30 +01:00
|
|
|
logDuplicateElements: function logDuplicateElements() {
|
|
|
|
var els = (0, _jQuery2.default)('*');
|
|
|
|
var dirty = false;
|
2016-03-04 04:40:54 +01:00
|
|
|
|
2016-01-11 02:25:30 +01:00
|
|
|
els.each(function (i, a) {
|
|
|
|
els.not(a).each(function (j, b) {
|
|
|
|
if (getHTML(a) == getHTML(b)) {
|
|
|
|
dirty = true;
|
|
|
|
console.log(a, b);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2016-03-04 04:40:54 +01:00
|
|
|
|
2016-01-11 02:25:30 +01:00
|
|
|
if (!dirty) console.log('No duplicates found');
|
|
|
|
},
|
2016-03-04 04:40:54 +01:00
|
|
|
|
2016-01-11 02:25:30 +01:00
|
|
|
logUncleanedElements: function logUncleanedElements(clean) {
|
|
|
|
_jQuery2.default.each(_jQuery2.default.cache, function () {
|
|
|
|
var source = this.handle && this.handle.elem;
|
|
|
|
if (!source) return;
|
2016-02-25 02:51:59 +01:00
|
|
|
|
2016-03-04 04:40:54 +01:00
|
|
|
var parent = source;
|
2016-01-11 02:25:30 +01:00
|
|
|
while (parent && parent.nodeType == 1) {
|
|
|
|
parent = parent.parentNode;
|
2016-03-04 04:40:54 +01:00
|
|
|
}if (!parent) {
|
2016-01-11 02:25:30 +01:00
|
|
|
console.log('Unattached', source);
|
|
|
|
console.log(this.events);
|
|
|
|
if (clean) (0, _jQuery2.default)(source).unbind().remove();
|
|
|
|
} else if (parent !== document) console.log('Attached, but to', parent, 'not our document', source);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
});
|