-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add option to refresh once during navigation (possible fix for #…
…320) chore: add es build chore: global window detection chore: small refactor improvements
- Loading branch information
Showing
12 changed files
with
145 additions
and
7 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
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
# Cleanup | ||
rm -rf lib es | ||
|
||
echo 'Compile JS...' | ||
rollup -c scripts/rollup.config.js | ||
echo 'Done.' | ||
echo '' | ||
|
||
echo 'Build ES modules...' | ||
NODE_ENV=es babel src --out-dir es --ignore 'src/browser.js' | ||
echo 'Done.' | ||
echo '' | ||
|
||
echo 'Done building assets.' |
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
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import batchUpdate from './batchUpdate' | ||
|
||
// store an id to keep track of DOM updates | ||
let batchId = null | ||
|
||
export default function triggerUpdate(vm, hookName) { | ||
if (vm.$root._vueMetaInitialized && !vm.$root._vueMetaPaused) { | ||
// batch potential DOM updates to prevent extraneous re-rendering | ||
batchId = batchUpdate(batchId, () => { | ||
vm.$meta().refresh() | ||
batchId = null | ||
}) | ||
} | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import isArray from './isArray' | ||
import { isObject } from './typeof' | ||
|
||
export function ensureIsArray(arg, key) { | ||
if (key && isObject(arg)) { | ||
if (!isArray(arg[key])) { | ||
arg[key] = [] | ||
} | ||
return arg | ||
} else { | ||
return isArray(arg) ? arg : [] | ||
} | ||
} | ||
|
||
export function ensuredPush(object, key, el) { | ||
ensureIsArray(object, key) | ||
|
||
object[key].push(el) | ||
} |
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
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
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,4 +1,5 @@ | ||
import { isObject } from '../shared/typeof' | ||
import { isObject } from './typeof' | ||
|
||
import { | ||
keyName, | ||
attribute, | ||
|
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export function pause(refresh = true) { | ||
this.$root._vueMetaPaused = true | ||
|
||
return () => resume(refresh) | ||
} | ||
|
||
export function resume(refresh = true) { | ||
this.$root._vueMetaPaused = false | ||
|
||
if (refresh) { | ||
return this.$root.$meta().refresh() | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { isUndefined } from './typeof' | ||
|
||
export function hasGlobalWindowFn() { | ||
try { | ||
return !isUndefined(window) | ||
} catch (e) { | ||
return false | ||
} | ||
} | ||
|
||
export const hasGlobalWindow = hasGlobalWindowFn() |
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import _getMetaInfo from '../src/shared/getMetaInfo' | ||
import { defaultOptions, loadVueMetaPlugin } from './utils' | ||
|
||
const getMetaInfo = (component, escapeSequences) => _getMetaInfo(defaultOptions, component, escapeSequences) | ||
|
||
describe('escaping', () => { | ||
let Vue | ||
|
||
beforeAll(() => (Vue = loadVueMetaPlugin())) | ||
|
||
test('special chars are escaped unless disabled', () => { | ||
const component = new Vue({ | ||
metaInfo: { | ||
title: 'Hello & Goodbye', | ||
script: [{ innerHTML: 'Hello & Goodbye' }], | ||
__dangerouslyDisableSanitizers: ['script'] | ||
} | ||
}) | ||
|
||
expect(getMetaInfo(component, [[/&/g, '&']])).toEqual({ | ||
title: 'Hello & Goodbye', | ||
titleChunk: 'Hello & Goodbye', | ||
titleTemplate: '%s', | ||
htmlAttrs: {}, | ||
headAttrs: {}, | ||
bodyAttrs: {}, | ||
meta: [], | ||
base: [], | ||
link: [], | ||
style: [], | ||
script: [{ innerHTML: 'Hello & Goodbye' }], | ||
noscript: [], | ||
__dangerouslyDisableSanitizers: ['script'], | ||
__dangerouslyDisableSanitizersByTagID: {} | ||
}) | ||
}) | ||
}) |