Skip to content

Commit

Permalink
feat(debug): Add proper render condition and console warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
apertureless committed Apr 5, 2018
1 parent 9395fab commit 3afe976
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/hideAt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
}
if (shouldRender) {
return this.$slots.default[0]
return this.$slots.default ? this.$slots.default[0] : null
}
return null
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/showAt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
}
if (shouldRender) {
return this.$slots.default[0]
return this.$slots.default ? this.$slots.default[0] : null
}
return null
}
Expand Down
5 changes: 5 additions & 0 deletions src/components/withBreakpoint.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
mounted () {
window.addEventListener('resize', this.handleResize)
this.handleResize()
if (this.$slots.default && this.$slots.default.length > 1) {
console.warn('[✋ vue-breakpoints] You may only wrap one element in a <showAt> or <hideAt/> component.')
} else if (!this.$slots.default || this.$slots.default.length < 1) {
console.warn('[✋ vue-breakpoints] You must have one child inside a <showAt> or <hideAt/> component.')
}
},
beforeDestroy () {
Expand Down

0 comments on commit 3afe976

Please sign in to comment.