aboutsummaryrefslogtreecommitdiff
path: root/node_modules/vue/src/core/util/env.js
diff options
context:
space:
mode:
authorruki <waruqi@gmail.com>2018-11-08 00:38:48 +0800
committerruki <waruqi@gmail.com>2018-11-07 21:53:09 +0800
commit26105034da4fcce7ac883c899d781f016559310d (patch)
treec459a5dc4e3aa0972d9919033ece511ce76dd129 /node_modules/vue/src/core/util/env.js
parent2c77f00f1a7ecb6c8192f9c16d3b2001b254a107 (diff)
downloadxmake-docs-26105034da4fcce7ac883c899d781f016559310d.tar.gz
xmake-docs-26105034da4fcce7ac883c899d781f016559310d.zip
switch to vuepress
Diffstat (limited to 'node_modules/vue/src/core/util/env.js')
-rw-r--r--node_modules/vue/src/core/util/env.js95
1 files changed, 95 insertions, 0 deletions
diff --git a/node_modules/vue/src/core/util/env.js b/node_modules/vue/src/core/util/env.js
new file mode 100644
index 00000000..07cadd9c
--- /dev/null
+++ b/node_modules/vue/src/core/util/env.js
@@ -0,0 +1,95 @@
+/* @flow */
+
+// can we use __proto__?
+export const hasProto = '__proto__' in {}
+
+// Browser environment sniffing
+export const inBrowser = typeof window !== 'undefined'
+export const inWeex = typeof WXEnvironment !== 'undefined' && !!WXEnvironment.platform
+export const weexPlatform = inWeex && WXEnvironment.platform.toLowerCase()
+export const UA = inBrowser && window.navigator.userAgent.toLowerCase()
+export const isIE = UA && /msie|trident/.test(UA)
+export const isIE9 = UA && UA.indexOf('msie 9.0') > 0
+export const isEdge = UA && UA.indexOf('edge/') > 0
+export const isAndroid = (UA && UA.indexOf('android') > 0) || (weexPlatform === 'android')
+export const isIOS = (UA && /iphone|ipad|ipod|ios/.test(UA)) || (weexPlatform === 'ios')
+export const isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge
+
+// Firefox has a "watch" function on Object.prototype...
+export const nativeWatch = ({}).watch
+
+export let supportsPassive = false
+if (inBrowser) {
+ try {
+ const opts = {}
+ Object.defineProperty(opts, 'passive', ({
+ get () {
+ /* istanbul ignore next */
+ supportsPassive = true
+ }
+ }: Object)) // https://github.com/facebook/flow/issues/285
+ window.addEventListener('test-passive', null, opts)
+ } catch (e) {}
+}
+
+// this needs to be lazy-evaled because vue may be required before
+// vue-server-renderer can set VUE_ENV
+let _isServer
+export const isServerRendering = () => {
+ if (_isServer === undefined) {
+ /* istanbul ignore if */
+ if (!inBrowser && !inWeex && typeof global !== 'undefined') {
+ // detect presence of vue-server-renderer and avoid
+ // Webpack shimming the process
+ _isServer = global['process'].env.VUE_ENV === 'server'
+ } else {
+ _isServer = false
+ }
+ }
+ return _isServer
+}
+
+// detect devtools
+export const devtools = inBrowser && window.__VUE_DEVTOOLS_GLOBAL_HOOK__
+
+/* istanbul ignore next */
+export function isNative (Ctor: any): boolean {
+ return typeof Ctor === 'function' && /native code/.test(Ctor.toString())
+}
+
+export const hasSymbol =
+ typeof Symbol !== 'undefined' && isNative(Symbol) &&
+ typeof Reflect !== 'undefined' && isNative(Reflect.ownKeys)
+
+let _Set
+/* istanbul ignore if */ // $flow-disable-line
+if (typeof Set !== 'undefined' && isNative(Set)) {
+ // use native Set when available.
+ _Set = Set
+} else {
+ // a non-standard Set polyfill that only works with primitive keys.
+ _Set = class Set implements SimpleSet {
+ set: Object;
+ constructor () {
+ this.set = Object.create(null)
+ }
+ has (key: string | number) {
+ return this.set[key] === true
+ }
+ add (key: string | number) {
+ this.set[key] = true
+ }
+ clear () {
+ this.set = Object.create(null)
+ }
+ }
+}
+
+interface SimpleSet {
+ has(key: string | number): boolean;
+ add(key: string | number): mixed;
+ clear(): void;
+}
+
+export { _Set }
+export type { SimpleSet }