Skip to content

Commit 3afe976

Browse files
committed
feat(debug): Add proper render condition and console warnings
1 parent 9395fab commit 3afe976

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/components/hideAt.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
}
4545
4646
if (shouldRender) {
47-
return this.$slots.default[0]
47+
return this.$slots.default ? this.$slots.default[0] : null
4848
}
4949
return null
5050
}

src/components/showAt.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
}
4545
4646
if (shouldRender) {
47-
return this.$slots.default[0]
47+
return this.$slots.default ? this.$slots.default[0] : null
4848
}
4949
return null
5050
}

src/components/withBreakpoint.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@
2323
mounted () {
2424
window.addEventListener('resize', this.handleResize)
2525
this.handleResize()
26+
if (this.$slots.default && this.$slots.default.length > 1) {
27+
console.warn('[✋ vue-breakpoints] You may only wrap one element in a <showAt> or <hideAt/> component.')
28+
} else if (!this.$slots.default || this.$slots.default.length < 1) {
29+
console.warn('[✋ vue-breakpoints] You must have one child inside a <showAt> or <hideAt/> component.')
30+
}
2631
},
2732
2833
beforeDestroy () {

0 commit comments

Comments
 (0)