]> git.sesse.net Git - remoteglot/commitdiff
Fix click-to-drag and click-to-suggest post-jQuery.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 25 Dec 2022 21:30:48 +0000 (22:30 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 25 Dec 2022 21:30:48 +0000 (22:30 +0100)
www/js/remoteglot.js

index bac1ef9711cb882dc196c451912bb678c484d180..0aa071aa35a6d88fe6527199eaa3d444a6595a3a 100644 (file)
@@ -2063,12 +2063,12 @@ let onDragStart = function(source, piece, position, orientation) {
 }
 
 let mousedownSquare = function(e) {
-       if (!e.target || !e.target.matches('.square-55d63')) {
+       if (!e.target || !e.target.closest('.square-55d63')) {
                return;
        }
 
        reverse_dragging_from = null;
-       let square = e.target.getAttribute('data-square');
+       let square = e.target.closest('.square-55d63').getAttribute('data-square');
 
        let pseudogame = new Chess(display_fen);
        if (pseudogame.game_over() === true) {
@@ -2093,13 +2093,13 @@ let mousedownSquare = function(e) {
 }
 
 let mouseupSquare = function(e) {
-       if (!e.target || !e.target.matches('.square-55d63')) {
+       if (!e.target || !e.target.closest('.square-55d63')) {
                return;
        }
        if (reverse_dragging_from === null) {
                return;
        }
-       let source = e.target.getAttribute('data-square');
+       let source = e.target.closest('.square-55d63').getAttribute('data-square');
        let target = reverse_dragging_from;
        reverse_dragging_from = null;
        if (onDrop(source, target) !== 'snapback') {