diff --git a/build/config.js b/build/config.js index e54a2e102..e30a733bf 100644 --- a/build/config.js +++ b/build/config.js @@ -1,5 +1,5 @@ module.exports = { dev: { - componentName: 'form', // dev components + componentName: 'spin', // dev components }, }; diff --git a/components/spin/Spin.jsx b/components/spin/Spin.jsx index bbd1e9f9f..4ee6a6cd5 100644 --- a/components/spin/Spin.jsx +++ b/components/spin/Spin.jsx @@ -30,12 +30,12 @@ function shouldDelay(spinning, delay) { return !!spinning && !!delay && !isNaN(Number(delay)); } -export function setDefaultIndicator(content) { +export function setDefaultIndicator(Content) { defaultIndicator = - typeof content.indicator === 'function' - ? content.indicator + typeof Content.indicator === 'function' + ? Content.indicator : h => { - return ; + return ; }; } @@ -69,14 +69,13 @@ export default { }); }, beforeDestroy() { - if (this.updateSpinning && this.updateSpinning.cancel) { - this.updateSpinning.cancel(); - } + this.cancelExistingSpin(); }, methods: { debouncifyUpdateSpinning(props) { const { delay } = props || this.$props; if (delay) { + this.cancelExistingSpin(); this.updateSpinning = debounce(this.originalUpdateSpinning, delay); } }, @@ -86,6 +85,12 @@ export default { this.setState({ sSpinning: spinning }); } }, + cancelExistingSpin() { + const { updateSpinning } = this; + if (updateSpinning && updateSpinning.cancel) { + updateSpinning.cancel(); + } + }, getChildren() { if (this.$slots && this.$slots.default) { return filterEmpty(this.$slots.default); @@ -96,6 +101,10 @@ export default { // const h = this.$createElement const dotClassName = `${prefixCls}-dot`; let indicator = getComponentFromProp(this, 'indicator'); + // should not be render default indicator when indicator value is null + if (indicator === null) { + return null; + } if (Array.isArray(indicator)) { indicator = filterEmpty(indicator); indicator = indicator.length === 1 ? indicator[0] : indicator; @@ -110,10 +119,10 @@ export default { return ( - - - - + + + + ); }, diff --git a/components/spin/__tests__/__snapshots__/demo.test.js.snap b/components/spin/__tests__/__snapshots__/demo.test.js.snap index ce2d33266..20b75fde0 100644 --- a/components/spin/__tests__/__snapshots__/demo.test.js.snap +++ b/components/spin/__tests__/__snapshots__/demo.test.js.snap @@ -2,7 +2,7 @@ exports[`renders ./components/spin/demo/basic.md correctly 1`] = `
-
+
`; @@ -33,7 +33,7 @@ exports[`renders ./components/spin/demo/delayAndDebounce.md correctly 1`] = ` exports[`renders ./components/spin/demo/inside.md correctly 1`] = `
-
+
`; @@ -52,9 +52,9 @@ exports[`renders ./components/spin/demo/nested.md correctly 1`] = ` exports[`renders ./components/spin/demo/size.md correctly 1`] = `
-
-
-
+
+
+
`; @@ -62,7 +62,7 @@ exports[`renders ./components/spin/demo/tip.md correctly 1`] = `
-
+
Loading...
diff --git a/components/spin/__tests__/__snapshots__/index.test.js.snap b/components/spin/__tests__/__snapshots__/index.test.js.snap index 1504b5333..1f3c0b334 100644 --- a/components/spin/__tests__/__snapshots__/index.test.js.snap +++ b/components/spin/__tests__/__snapshots__/index.test.js.snap @@ -3,7 +3,7 @@ exports[`Spin should only affect the spin element when set style to a nested xx 1`] = `
-
+
content