MDL-68167 lib: The accessibleChange custom event now supports bubbling
authorShamim Rezaie <shamim@moodle.com>
Tue, 28 Jul 2020 08:26:22 +0000 (18:26 +1000)
committerShamim Rezaie <shamim@moodle.com>
Fri, 30 Oct 2020 03:52:52 +0000 (14:52 +1100)
The change event bubbles so the accessibleChange shoud bubble as well.

lib/amd/build/custom_interaction_events.min.js
lib/amd/build/custom_interaction_events.min.js.map
lib/amd/src/custom_interaction_events.js

index f2ddae7..fdf405e 100644 (file)
Binary files a/lib/amd/build/custom_interaction_events.min.js and b/lib/amd/build/custom_interaction_events.min.js differ
index 7e05919..2ca3bca 100644 (file)
Binary files a/lib/amd/build/custom_interaction_events.min.js.map and b/lib/amd/build/custom_interaction_events.min.js.map differ
index 674fffa..84f09d2 100644 (file)
@@ -431,27 +431,27 @@ define(['jquery', 'core/key_codes'], function($, keyCodes) {
                 triggerEvent(events.accessibleChange, e);
             });
         } else {
-            element.on('focus', function() {
-                $(this).data('initValue', this.value);
+            element.on('focusin', function(e) {
+                $(e.target).data('initValue', e.target.value);
             });
-            element.on('blur', function(e) {
-                var initValue = $(this).data('initValue');
-                $(this).removeData('initValue');
-                if (this.value !== initValue) {
+            element.on('focusout', function(e) {
+                var initValue = $(e.target).data('initValue');
+                $(e.target).removeData('initValue');
+                if (e.target.value !== initValue) {
                     triggerEvent(events.accessibleChange, e);
                 }
             });
             element.on('keydown', function(e) {
-                if ((e.which === keyCodes.enter) && this.value !== $(this).data('initValue')) {
+                if ((e.which === keyCodes.enter) && e.target.value !== $(e.target).data('initValue')) {
                     triggerEvent(events.accessibleChange, e);
                 } else if (e.which === keyCodes.escape) {
-                    this.value = $(this).data('initValue');
+                    e.target.value = $(e.target).data('initValue');
                 }
             });
             element.on('click', function(e) {
-                var initValue = $(this).data('initValue');
+                var initValue = $(e.target).data('initValue');
                 // Some browsers trigger onclick before onblur, therefore it is possible that initValue is undefined.
-                if (typeof initValue !== 'undefined' && initValue != this.value) {
+                if (typeof initValue !== 'undefined' && initValue != e.target.value) {
                     triggerEvent(events.accessibleChange, e);
                 }
             });