drop jQuery support completely from knockoutjs

This commit is contained in:
djmaze 2020-09-21 16:11:06 +02:00
parent 06abbf0713
commit 1cd07955a2
5 changed files with 110 additions and 140 deletions

View file

@ -1,7 +1,6 @@
// For any options that may affect various areas of Knockout and aren't directly associated with data binding.
ko.options = {
'deferUpdates': false,
'useOnlyNativeEvents': false,
'foreachHidesDestroyed': false
};

View file

@ -28,9 +28,6 @@ ko.utils.domNodeDisposal = new (function () {
// Erase the DOM data
ko.utils.domData.clear(node);
// Perform cleanup needed by external libraries (currently only jQuery, but can be extended)
ko.utils.domNodeDisposal["cleanExternalData"](node);
// Clear any immediate-child comment nodes, as these wouldn't have been found by
// node.getElementsByTagName("*") in cleanNode() (comment nodes aren't elements)
if (cleanableNodeTypesWithDescendants[node.nodeType]) {
@ -86,14 +83,6 @@ ko.utils.domNodeDisposal = new (function () {
ko.cleanNode(node);
if (node.parentNode)
node.parentNode.removeChild(node);
},
'cleanExternalData' : function (node) {
// Special support for jQuery here because it's so commonly used.
// Many jQuery plugins (including jquery.tmpl) store data using jQuery's equivalent of domData
// so notify it to tear down any resources associated with the node & descendants here.
if (jQuery && jQuery['cleanData'])
jQuery['cleanData']([node]);
}
};
})();

View file

@ -246,10 +246,7 @@ ko.utils = (function () {
registerEventHandler: function (element, eventType, handler) {
var wrappedHandler = ko.utils.catchFunctionErrors(handler);
if (!ko.options['useOnlyNativeEvents'] && jQuery) {
jQuery(element)['on'](eventType, wrappedHandler);
} else
element.addEventListener(eventType, wrappedHandler, false);
element.addEventListener(eventType, wrappedHandler, false);
},
triggerEvent: function (element, eventType) {