瀏覽代碼

Change the destruction order for extensions.

NaotoshiFujita 3 年之前
父節點
當前提交
174ad02f53

文件差異過大導致無法顯示
+ 1 - 1
dist/js/splide-renderer.min.js


+ 5 - 4
dist/js/splide.cjs.js

@@ -1,6 +1,6 @@
 /*!
  * Splide.js
- * Version  : 3.1.7
+ * Version  : 3.1.8
  * License  : MIT
  * Copyright: 2021 Naotoshi Fujita
  */
@@ -119,9 +119,10 @@ function child(parent, selector) {
   return selector ? children(parent, selector)[0] : parent.firstElementChild;
 }
 
-function forOwn(object, iteratee) {
+function forOwn(object, iteratee, right) {
   if (object) {
-    const keys = Object.keys(object);
+    let keys = Object.keys(object);
+    keys = right ? keys.reverse() : keys;
     for (let i = 0; i < keys.length; i++) {
       const key = keys[i];
       if (key !== "__proto__") {
@@ -2367,7 +2368,7 @@ const _Splide = class {
     } else {
       forOwn(this._Components, (component) => {
         component.destroy && component.destroy(completely);
-      });
+      }, true);
       event.emit(EVENT_DESTROY);
       event.destroy();
       completely && empty(this.splides);

+ 5 - 4
dist/js/splide.esm.js

@@ -1,6 +1,6 @@
 /*!
  * Splide.js
- * Version  : 3.1.7
+ * Version  : 3.1.8
  * License  : MIT
  * Copyright: 2021 Naotoshi Fujita
  */
@@ -115,9 +115,10 @@ function child(parent, selector) {
   return selector ? children(parent, selector)[0] : parent.firstElementChild;
 }
 
-function forOwn(object, iteratee) {
+function forOwn(object, iteratee, right) {
   if (object) {
-    const keys = Object.keys(object);
+    let keys = Object.keys(object);
+    keys = right ? keys.reverse() : keys;
     for (let i = 0; i < keys.length; i++) {
       const key = keys[i];
       if (key !== "__proto__") {
@@ -2363,7 +2364,7 @@ const _Splide = class {
     } else {
       forOwn(this._Components, (component) => {
         component.destroy && component.destroy(completely);
-      });
+      }, true);
       event.emit(EVENT_DESTROY);
       event.destroy();
       completely && empty(this.splides);

+ 4 - 3
dist/js/splide.js

@@ -4,7 +4,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
 
 /*!
  * Splide.js
- * Version  : 3.1.7
+ * Version  : 3.1.8
  * License  : MIT
  * Copyright: 2021 Naotoshi Fujita
  */
@@ -131,9 +131,10 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
     return selector ? children(parent, selector)[0] : parent.firstElementChild;
   }
 
-  function forOwn(object, iteratee) {
+  function forOwn(object, iteratee, right) {
     if (object) {
       var keys = Object.keys(object);
+      keys = right ? keys.reverse() : keys;
 
       for (var i = 0; i < keys.length; i++) {
         var key = keys[i];
@@ -2901,7 +2902,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
       } else {
         forOwn(this._Components, function (component) {
           component.destroy && component.destroy(completely);
-        });
+        }, true);
         event.emit(EVENT_DESTROY);
         event.destroy();
         completely && empty(this.splides);

文件差異過大導致無法顯示
+ 0 - 0
dist/js/splide.js.map


文件差異過大導致無法顯示
+ 1 - 1
dist/js/splide.min.js


二進制
dist/js/splide.min.js.gz


+ 7 - 0
dist/types/utils/dom/focus/focus.d.ts

@@ -0,0 +1,7 @@
+/**
+ * Focuses the provided element without scrolling the ascendant element.
+ *
+ * @param elm - An element to focus.
+ */
+export declare function focus(elm: HTMLElement): void;
+//# sourceMappingURL=../../../../../src/js/utils/dom/focus/focus.d.ts.map

+ 1 - 0
dist/types/utils/dom/focus/focus.d.ts.map

@@ -0,0 +1 @@
+{"version":3,"file":"focus.d.ts","sourceRoot":"","sources":["focus.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,wBAAgB,KAAK,CAAE,GAAG,EAAE,WAAW,GAAI,IAAI,CAE9C"}

+ 2 - 1
dist/types/utils/object/forOwn/forOwn.d.ts

@@ -3,8 +3,9 @@
  *
  * @param object   - An object to iterate over.
  * @param iteratee - An iteratee function that takes the value and key as arguments.
+ * @param right    - If `true`, the method iterates over the object from the end like `forEachRight()`.
  *
  * @return A provided object itself.
  */
-export declare function forOwn<T extends object>(object: T, iteratee: (value: T[keyof T], key: string) => boolean | void): T;
+export declare function forOwn<T extends object>(object: T, iteratee: (value: T[keyof T], key: string) => boolean | void, right?: boolean): T;
 //# sourceMappingURL=../../../../../src/js/utils/object/forOwn/forOwn.d.ts.map

+ 1 - 1
dist/types/utils/object/forOwn/forOwn.d.ts.map

@@ -1 +1 @@
-{"version":3,"file":"forOwn.d.ts","sourceRoot":"","sources":["forOwn.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,EACrC,MAAM,EAAE,CAAC,EACT,QAAQ,EAAE,CAAE,KAAK,EAAE,CAAC,CAAE,MAAM,CAAC,CAAE,EAAE,GAAG,EAAE,MAAM,KAAM,OAAO,GAAG,IAAI,GAC/D,CAAC,CAgBH"}
+{"version":3,"file":"forOwn.d.ts","sourceRoot":"","sources":["forOwn.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,MAAM,EACrC,MAAM,EAAE,CAAC,EACT,QAAQ,EAAE,CAAE,KAAK,EAAE,CAAC,CAAE,MAAM,CAAC,CAAE,EAAE,GAAG,EAAE,MAAM,KAAM,OAAO,GAAG,IAAI,EAChE,KAAK,CAAC,EAAE,OAAO,GACd,CAAC,CAiBH"}

+ 1 - 1
package-lock.json

@@ -1,6 +1,6 @@
 {
   "name": "@splidejs/splide",
-  "version": "3.1.7",
+  "version": "3.1.8",
   "lockfileVersion": 1,
   "requires": true,
   "dependencies": {

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "@splidejs/splide",
-  "version": "3.1.7",
+  "version": "3.1.8",
   "description": "Splide is a lightweight, flexible and accessible slider/carousel. No dependencies, no Lighthouse errors.",
   "author": "Naotoshi Fujita",
   "license": "MIT",

+ 1 - 1
src/js/core/Splide/Splide.ts

@@ -335,7 +335,7 @@ export class Splide {
     } else {
       forOwn( this._Components, component => {
         component.destroy && component.destroy( completely );
-      } );
+      }, true );
 
       event.emit( EVENT_DESTROY );
       event.destroy();

+ 1 - 1
src/js/utils/dom/focus/focus.ts

@@ -4,5 +4,5 @@
  * @param elm - An element to focus.
  */
 export function focus( elm: HTMLElement ): void {
-  elm[ 'setActive' ] && elm[ 'setActive' ]() || elm.focus( { preventScroll: true } )
+  elm[ 'setActive' ] && elm[ 'setActive' ]() || elm.focus( { preventScroll: true } );
 }

+ 11 - 0
src/js/utils/object/forOwn/forOwn.test.ts

@@ -14,6 +14,17 @@ describe( 'forOwn', () => {
     expect( counter ).toBe( Object.keys( object ).length );
   } );
 
+  test( 'can iterate an object from the end.', () => {
+    const object = { a: 1, b: 2, c: 3 };
+    const values: number[] = [];
+
+    forOwn( object, ( value ) => {
+      values.push( value );
+    }, true );
+
+    expect( values ).toEqual( [ 3, 2, 1 ] );
+  } );
+
   test( 'should not handle inherited properties.', () => {
     class Constructor {
       a = 1;

+ 5 - 2
src/js/utils/object/forOwn/forOwn.ts

@@ -3,15 +3,18 @@
  *
  * @param object   - An object to iterate over.
  * @param iteratee - An iteratee function that takes the value and key as arguments.
+ * @param right    - If `true`, the method iterates over the object from the end like `forEachRight()`.
  *
  * @return A provided object itself.
  */
 export function forOwn<T extends object>(
   object: T,
-  iteratee: ( value: T[ keyof T ], key: string ) => boolean | void
+  iteratee: ( value: T[ keyof T ], key: string ) => boolean | void,
+  right?: boolean
 ): T {
   if ( object ) {
-    const keys = Object.keys( object );
+    let keys = Object.keys( object );
+    keys = right ? keys.reverse() : keys;
 
     for ( let i = 0; i < keys.length; i++ ) {
       const key = keys[ i ];

部分文件因文件數量過多而無法顯示