Jelajahi Sumber

fixed color picker leak

Nicolas Cannasse 4 tahun lalu
induk
melakukan
91d156684d
2 mengubah file dengan 6 tambahan dan 6 penghapusan
  1. 5 4
      bin/libs/spectrum.js
  2. 1 2
      hide/comp/ColorPicker.hx

+ 5 - 4
bin/libs/spectrum.js

@@ -1138,7 +1138,7 @@
     /**
     /**
     * Define a jQuery plugin
     * Define a jQuery plugin
     */
     */
-    var dataID = "spectrum.id";
+    var dataID = "__spectrum_id";
     $.fn.spectrum = function (opts, extra) {
     $.fn.spectrum = function (opts, extra) {
 
 
         if (typeof opts == "string") {
         if (typeof opts == "string") {
@@ -1147,7 +1147,8 @@
             var args = Array.prototype.slice.call( arguments, 1 );
             var args = Array.prototype.slice.call( arguments, 1 );
 
 
             this.each(function () {
             this.each(function () {
-                var spect = spectrums[$(this).data(dataID)];
+				var id = this[dataID];
+                var spect = spectrums[id];
                 if (spect) {
                 if (spect) {
                     var method = spect[opts];
                     var method = spect[opts];
                     if (!method) {
                     if (!method) {
@@ -1165,7 +1166,7 @@
                     }
                     }
                     else if (opts == "destroy") {
                     else if (opts == "destroy") {
                         spect.destroy();
                         spect.destroy();
-                        $(this).removeData(dataID);
+                        this[dataID] = undefined;
                     }
                     }
                     else {
                     else {
                         method.apply(spect, args);
                         method.apply(spect, args);
@@ -1180,7 +1181,7 @@
         return this.spectrum("destroy").each(function () {
         return this.spectrum("destroy").each(function () {
             var options = $.extend({}, opts, $(this).data());
             var options = $.extend({}, opts, $(this).data());
             var spect = spectrum(this, options);
             var spect = spectrum(this, options);
-            $(this).data(dataID, spect.id);
+			this[dataID] = spect.id;
         });
         });
     };
     };
 
 

+ 1 - 2
hide/comp/ColorPicker.hx

@@ -32,11 +32,10 @@ class ColorPicker extends Component {
 		});
 		});
 
 
 		// cleanup
 		// cleanup
-		var container = (element:Dynamic).spectrum("container");
 		var timer = new haxe.Timer(1000);
 		var timer = new haxe.Timer(1000);
 		timer.run = function() {
 		timer.run = function() {
 			if( root.parents("body").length == 0 ) {
 			if( root.parents("body").length == 0 ) {
-				container.remove();
+				(element:Dynamic).spectrum("destroy");
 				timer.stop();
 				timer.stop();
 			}
 			}
 		};
 		};