This repository was archived by the owner on Dec 31, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11/* @flow */
22
33import VueI18n from './index'
4- import { typeName , isPlainObject , warn } from './util'
4+ import { isPlainObject , warn } from './util'
55
66export default {
77 computed : {
@@ -45,11 +45,11 @@ export default {
4545 beforeCreate ( ) {
4646 const options : any = this . $options
4747 if ( options . i18n ) {
48- if ( typeName ( options . i18n ) === ' VueI18n' ) {
48+ if ( options . i18n instanceof VueI18n ) {
4949 this . $i18n = options . i18n
5050 } else if ( isPlainObject ( options . i18n ) ) {
5151 // component local i18n
52- if ( this . $root && this . $root . $i18n && typeName ( this . $root . $i18n ) === ' VueI18n' ) {
52+ if ( this . $root && this . $root . $i18n && this . $root . $i18n instanceof VueI18n ) {
5353 options . i18n . root = this . $root . $i18n
5454 }
5555 this . $i18n = new VueI18n ( options . i18n )
@@ -61,7 +61,7 @@ export default {
6161 warn ( `Cannot be interpreted 'i18n' option.` )
6262 }
6363 }
64- } else if ( this . $root && this . $root . $i18n && typeName ( this . $root . $i18n ) === ' VueI18n' ) {
64+ } else if ( this . $root && this . $root . $i18n && this . $root . $i18n instanceof VueI18n ) {
6565 // root i18n
6666 this . $i18n = this . $root . $i18n
6767 }
Original file line number Diff line number Diff line change @@ -42,27 +42,6 @@ export function isPlainObject (obj: any): boolean {
4242 return toString . call ( obj ) === OBJECT_STRING
4343}
4444
45- function funcName ( f : Function ) : string {
46- if ( f . name ) { return f . name }
47- const match = / ^ \s * f u n c t i o n \s * ( [ ^ \( ] * ) / im. exec ( f . toString ( ) )
48- return match ? match [ 1 ] : ''
49- }
50-
51- function ctorName ( obj : any ) : string {
52- const str = toString . call ( obj ) . slice ( 8 , - 1 )
53- if ( ( str === 'Object' || str === 'Error' ) && obj . constructor ) {
54- return funcName ( obj . constructor )
55- }
56- return str
57- }
58-
59- export function typeName ( val : mixed ) : string {
60- if ( val === null ) { return 'null' }
61- const type : string = typeof val
62- if ( type === 'object' ) { return ctorName ( val ) }
63- return type
64- }
65-
6645export function isNull ( val : mixed ) : boolean {
6746 return val === null || val === undefined
6847}
You can’t perform that action at this time.
0 commit comments