Use JavaScript Optional chaining in vendors/*

This commit is contained in:
the-djmaze 2022-09-12 22:07:51 +02:00
parent e5e4675c1b
commit ef8b1f40e4
28 changed files with 619 additions and 750 deletions

View file

@ -9,7 +9,7 @@ ko.utils = {
// Ensure it's a real array, as we're about to reparent the nodes and
// we don't want the underlying collection to change while we're doing that.
var nodesArray = [...nodes];
var templateDocument = (nodesArray[0] && nodesArray[0].ownerDocument) || document;
var templateDocument = nodesArray[0]?.ownerDocument || document;
var container = templateDocument.createElement('div');
nodesArray.forEach(node => container.append(ko.cleanNode(node)));
@ -80,7 +80,7 @@ ko.utils = {
node.ownerDocument.documentElement.contains(node.nodeType !== 1 ? node.parentNode : node),
triggerEvent: (element, eventType) => {
if (!(element && element.nodeType))
if (!element?.nodeType)
throw new Error("element must be a DOM node when calling triggerEvent");
element.dispatchEvent(new Event(eventType));