DataTransfer#types: contains() -> includes()

Not sure what this was before, but it's a standard read-only array now.

Fixes #4893
This commit is contained in:
Abe Jellinek 2024-12-03 15:32:19 -05:00 committed by Dan Stillman
parent a96b7f1b68
commit f28fa763cc
4 changed files with 7 additions and 7 deletions

View file

@ -1497,7 +1497,7 @@ var CollectionTree = class CollectionTree extends LibraryTree {
// And everything else is a move
this.setDropEffect(event, "move");
}
else if (event.dataTransfer.types.contains("application/x-moz-file")) {
else if (event.dataTransfer.types.includes("application/x-moz-file")) {
// As of Aug. 2013 nightlies:
//
// - Setting the dropEffect only works on Linux and OS X.

View file

@ -2122,7 +2122,7 @@ var ItemTree = class ItemTree extends LibraryTree {
this.setDropEffect(event, "copy");
}
}
else if (event.dataTransfer.types.contains("application/x-moz-file")) {
else if (event.dataTransfer.types.includes("application/x-moz-file")) {
// As of Aug. 2013 nightlies:
//
// - Setting the dropEffect only works on Linux and OS X.

View file

@ -2035,18 +2035,18 @@ Zotero.DragDrop = {
var len = firstOnly ? 1 : dt.mozItemCount;
if (dt.types.contains('zotero/collection')) {
if (dt.types.includes('zotero/collection')) {
dragData.dataType = 'zotero/collection';
let ids = dt.getData('zotero/collection').split(",").map(id => parseInt(id));
dragData.data = ids;
}
else if (dt.types.contains('zotero/item')) {
else if (dt.types.includes('zotero/item')) {
dragData.dataType = 'zotero/item';
let ids = dt.getData('zotero/item').split(",").map(id => parseInt(id));
dragData.data = ids;
}
else {
if (dt.types.contains('application/x-moz-file')) {
if (dt.types.includes('application/x-moz-file')) {
dragData.dataType = 'application/x-moz-file';
var files = [];
for (var i=0; i<len; i++) {
@ -2065,7 +2065,7 @@ Zotero.DragDrop = {
}
// This isn't an else because on Linux a link drag contains an empty application/x-moz-file too
if (!dragData.data || !dragData.data.length) {
if (dt.types.contains('text/x-moz-url')) {
if (dt.types.includes('text/x-moz-url')) {
dragData.dataType = 'text/x-moz-url';
var urls = [];
for (var i=0; i<len; i++) {

View file

@ -982,7 +982,7 @@ describe("Zotero.ItemTree", function() {
var event = { dataTransfer };
// On macOS, ItemTree checks modifier keys, not just the dropEffect
if (Zotero.isMac
&& dataTransfer.types.contains('application/x-moz-file')) {
&& dataTransfer.types.includes('application/x-moz-file')) {
switch (dataTransfer.dropEffect) {
case 'link':
event.metaKey = true;