-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: remove nested div from dummy element
- Loading branch information
1 parent
fa44dac
commit 34e8180
Showing
2 changed files
with
14 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
export default { | ||
functional: true, | ||
render (h, { children, props: { regex, invert } }) { | ||
render (h, { children, slots, props: { regex, invert } }) { | ||
const dummyEl = h('div', {}, []) | ||
if (process.server) { | ||
return dummyEl | ||
} | ||
|
||
const botRegex = regex || /bot|googlebot|crawler|spider|robot|crawling/i | ||
const isBot = process.server ? true : navigator.userAgent && botRegex.test(navigator.userAgent) | ||
const isBot = navigator.userAgent && botRegex.test(navigator.userAgent) | ||
const shouldShow = invert ? isBot : !isBot | ||
|
||
return h('div', {}, shouldShow ? children : [h('div')]) | ||
if (!shouldShow) { | ||
return dummyEl | ||
} | ||
|
||
return h('div', {}, slots().default) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters