move window MutationObserver to beforeMount for SSR

This commit is contained in:
DaxChen
2017-10-06 16:54:27 +08:00
parent 2573c3e2c8
commit 5103a3039c
3 changed files with 36 additions and 35 deletions

19
dist/index.js vendored

File diff suppressed because one or more lines are too long

19
dist/ssr.index.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -33,23 +33,6 @@
import { inRange } from './util'
import parseNumber from './parser'
/**
* MutationObserver feature detection:
* Detects if MutationObserver is available, return false if not.
* No polyfill is provided here, so height 'auto' recalculation will simply stay at its initial height (won't crash).
* (Provide polyfill to support IE < 11)
*/
const MutationObserver = (function () {
const prefixes = ['', 'WebKit', 'Moz', 'O', 'Ms']
for (let i = 0; i < prefixes.length; i++) {
if (prefixes[i] + 'MutationObserver' in window) {
console.log('got MutationObserver:', prefixes[i] + 'MutationObserver')
return window[prefixes[i] + 'MutationObserver']
}
}
return false
}())
export default {
name: 'VueJsModal',
props: {
@@ -241,6 +224,22 @@
}
// init MutationObserver
/**
* MutationObserver feature detection:
* Detects if MutationObserver is available, return false if not.
* No polyfill is provided here, so height 'auto' recalculation will simply stay at its initial height (won't crash).
* (Provide polyfill to support IE < 11)
*/
const MutationObserver = (function () {
const prefixes = ['', 'WebKit', 'Moz', 'O', 'Ms']
for (let i = 0; i < prefixes.length; i++) {
if (prefixes[i] + 'MutationObserver' in window) {
console.log('got MutationObserver:', prefixes[i] + 'MutationObserver')
return window[prefixes[i] + 'MutationObserver']
}
}
return false
}())
// Only observe when using height: 'auto'
// The callback will be called when modal DOM changes,
// this is for updating the `top` attribute for height 'auto' modals.