Skip to content

Commit

Permalink
fix(weex): donot rethrow the captured error on weex platform (#7024)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hanks10100 authored and yyx990803 committed Nov 13, 2017
1 parent 0496115 commit c2b1cfe
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/core/util/env.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
/* @flow */
declare var WXEnvironment: any;

// 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
export const isIOS = UA && /iphone|ipad|ipod|ios/.test(UA)
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...
Expand Down
4 changes: 2 additions & 2 deletions src/core/util/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import config from '../config'
import { warn } from './debug'
import { inBrowser } from './env'
import { inBrowser, inWeex } from './env'

export function handleError (err: Error, vm: any, info: string) {
if (vm) {
Expand Down Expand Up @@ -40,7 +40,7 @@ function logError (err, vm, info) {
warn(`Error in ${info}: "${err.toString()}"`, vm)
}
/* istanbul ignore else */
if (inBrowser && typeof console !== 'undefined') {
if ((inBrowser || inWeex) && typeof console !== 'undefined') {
console.error(err)
} else {
throw err
Expand Down

0 comments on commit c2b1cfe

Please sign in to comment.