@@ -119,14 +119,14 @@ export function parse(template: string, options: CompilerOptions): ASTElement {
119119 if ( ! stack . length && element !== root ) {
120120 // allow root elements with v-if, v-else-if and v-else
121121 if ( root . if && ( element . elseif || element . else ) ) {
122- if ( process . env . NODE_ENV !== 'production' ) {
122+ if ( __DEV__ ) {
123123 checkRootConstraints ( element )
124124 }
125125 addIfCondition ( root , {
126126 exp : element . elseif ,
127127 block : element
128128 } )
129- } else if ( process . env . NODE_ENV !== 'production' ) {
129+ } else if ( __DEV__ ) {
130130 warnOnce (
131131 `Component template should contain exactly one root element. ` +
132132 `If you are using v-if on multiple elements, ` +
@@ -229,7 +229,7 @@ export function parse(template: string, options: CompilerOptions): ASTElement {
229229 element . ns = ns
230230 }
231231
232- if ( process . env . NODE_ENV !== 'production' ) {
232+ if ( __DEV__ ) {
233233 if ( options . outputSourceRange ) {
234234 element . start = start
235235 element . end = end
@@ -254,7 +254,7 @@ export function parse(template: string, options: CompilerOptions): ASTElement {
254254
255255 if ( isForbiddenTag ( element ) && ! isServerRendering ( ) ) {
256256 element . forbidden = true
257- process . env . NODE_ENV !== 'production' &&
257+ __DEV__ &&
258258 warn (
259259 'Templates should only be responsible for mapping the state to the ' +
260260 'UI. Avoid placing tags with side-effects in your templates, such as ' +
@@ -289,7 +289,7 @@ export function parse(template: string, options: CompilerOptions): ASTElement {
289289
290290 if ( ! root ) {
291291 root = element
292- if ( process . env . NODE_ENV !== 'production' ) {
292+ if ( __DEV__ ) {
293293 checkRootConstraints ( root )
294294 }
295295 }
@@ -307,15 +307,15 @@ export function parse(template: string, options: CompilerOptions): ASTElement {
307307 // pop stack
308308 stack . length -= 1
309309 currentParent = stack [ stack . length - 1 ]
310- if ( process . env . NODE_ENV !== 'production' && options . outputSourceRange ) {
310+ if ( __DEV__ && options . outputSourceRange ) {
311311 element . end = end
312312 }
313313 closeElement ( element )
314314 } ,
315315
316316 chars ( text : string , start : number , end : number ) {
317317 if ( ! currentParent ) {
318- if ( process . env . NODE_ENV !== 'production' ) {
318+ if ( __DEV__ ) {
319319 if ( text === template ) {
320320 warnOnce (
321321 'Component template requires a root element, rather than just text.' ,
@@ -382,10 +382,7 @@ export function parse(template: string, options: CompilerOptions): ASTElement {
382382 }
383383 }
384384 if ( child ) {
385- if (
386- process . env . NODE_ENV !== 'production' &&
387- options . outputSourceRange
388- ) {
385+ if ( __DEV__ && options . outputSourceRange ) {
389386 child . start = start
390387 child . end = end
391388 }
@@ -402,10 +399,7 @@ export function parse(template: string, options: CompilerOptions): ASTElement {
402399 text,
403400 isComment : true
404401 }
405- if (
406- process . env . NODE_ENV !== 'production' &&
407- options . outputSourceRange
408- ) {
402+ if ( __DEV__ && options . outputSourceRange ) {
409403 child . start = start
410404 child . end = end
411405 }
@@ -465,7 +459,7 @@ export function processElement(element: ASTElement, options: CompilerOptions) {
465459function processKey ( el ) {
466460 const exp = getBindingAttr ( el , 'key' )
467461 if ( exp ) {
468- if ( process . env . NODE_ENV !== 'production' ) {
462+ if ( __DEV__ ) {
469463 if ( el . tag === 'template' ) {
470464 warn (
471465 `<template> cannot be keyed. Place the key on real elements instead.` ,
@@ -508,7 +502,7 @@ export function processFor(el: ASTElement) {
508502 const res = parseFor ( exp )
509503 if ( res ) {
510504 extend ( el , res )
511- } else if ( process . env . NODE_ENV !== 'production' ) {
505+ } else if ( __DEV__ ) {
512506 warn ( `Invalid v-for expression: ${ exp } ` , el . rawAttrsMap [ 'v-for' ] )
513507 }
514508 }
@@ -566,7 +560,7 @@ function processIfConditions(el, parent) {
566560 exp : el . elseif ,
567561 block : el
568562 } )
569- } else if ( process . env . NODE_ENV !== 'production' ) {
563+ } else if ( __DEV__ ) {
570564 warn (
571565 `v-${ el . elseif ? 'else-if="' + el . elseif + '"' : 'else' } ` +
572566 `used on element <${ el . tag } > without corresponding v-if.` ,
@@ -581,7 +575,7 @@ function findPrevElement(children: Array<any>): ASTElement | void {
581575 if ( children [ i ] . type === 1 ) {
582576 return children [ i ]
583577 } else {
584- if ( process . env . NODE_ENV !== 'production' && children [ i ] . text !== ' ' ) {
578+ if ( __DEV__ && children [ i ] . text !== ' ' ) {
585579 warn (
586580 `text "${ children [ i ] . text . trim ( ) } " between v-if and v-else(-if) ` +
587581 `will be ignored.` ,
@@ -614,7 +608,7 @@ function processSlotContent(el) {
614608 if ( el . tag === 'template' ) {
615609 slotScope = getAndRemoveAttr ( el , 'scope' )
616610 /* istanbul ignore if */
617- if ( process . env . NODE_ENV !== 'production' && slotScope ) {
611+ if ( __DEV__ && slotScope ) {
618612 warn (
619613 `the "scope" attribute for scoped slots have been deprecated and ` +
620614 `replaced by "slot-scope" since 2.5. The new "slot-scope" attribute ` +
@@ -627,7 +621,7 @@ function processSlotContent(el) {
627621 el . slotScope = slotScope || getAndRemoveAttr ( el , 'slot-scope' )
628622 } else if ( ( slotScope = getAndRemoveAttr ( el , 'slot-scope' ) ) ) {
629623 /* istanbul ignore if */
630- if ( process . env . NODE_ENV !== 'production' && el . attrsMap [ 'v-for' ] ) {
624+ if ( __DEV__ && el . attrsMap [ 'v-for' ] ) {
631625 warn (
632626 `Ambiguous combined usage of slot-scope and v-for on <${ el . tag } > ` +
633627 `(v-for takes higher priority). Use a wrapper <template> for the ` +
@@ -659,7 +653,7 @@ function processSlotContent(el) {
659653 // v-slot on <template>
660654 const slotBinding = getAndRemoveAttrByRegex ( el , slotRE )
661655 if ( slotBinding ) {
662- if ( process . env . NODE_ENV !== 'production' ) {
656+ if ( __DEV__ ) {
663657 if ( el . slotTarget || el . slotScope ) {
664658 warn ( `Unexpected mixed usage of different slot syntaxes.` , el )
665659 }
@@ -680,7 +674,7 @@ function processSlotContent(el) {
680674 // v-slot on component, denotes default slot
681675 const slotBinding = getAndRemoveAttrByRegex ( el , slotRE )
682676 if ( slotBinding ) {
683- if ( process . env . NODE_ENV !== 'production' ) {
677+ if ( __DEV__ ) {
684678 if ( ! maybeComponent ( el ) ) {
685679 warn (
686680 `v-slot can only be used on components or <template>.` ,
@@ -729,7 +723,7 @@ function getSlotName(binding) {
729723 if ( ! name ) {
730724 if ( binding . name [ 0 ] !== '#' ) {
731725 name = 'default'
732- } else if ( process . env . NODE_ENV !== 'production' ) {
726+ } else if ( __DEV__ ) {
733727 warn ( `v-slot shorthand syntax requires a slot name.` , binding )
734728 }
735729 }
@@ -744,7 +738,7 @@ function getSlotName(binding) {
744738function processSlotOutlet ( el ) {
745739 if ( el . tag === 'slot' ) {
746740 el . slotName = getBindingAttr ( el , 'name' )
747- if ( process . env . NODE_ENV !== 'production' && el . key ) {
741+ if ( __DEV__ && el . key ) {
748742 warn (
749743 `\`key\` does not work on <slot> because slots are abstract outlets ` +
750744 `and can possibly expand into multiple elements. ` +
@@ -791,10 +785,7 @@ function processAttrs(el) {
791785 if ( isDynamic ) {
792786 name = name . slice ( 1 , - 1 )
793787 }
794- if (
795- process . env . NODE_ENV !== 'production' &&
796- value . trim ( ) . length === 0
797- ) {
788+ if ( __DEV__ && value . trim ( ) . length === 0 ) {
798789 warn (
799790 `The value for a v-bind expression cannot be empty. Found in "v-bind:${ name } "`
800791 )
@@ -885,13 +876,13 @@ function processAttrs(el) {
885876 modifiers ,
886877 list [ i ]
887878 )
888- if ( process . env . NODE_ENV !== 'production' && name === 'model' ) {
879+ if ( __DEV__ && name === 'model' ) {
889880 checkForAliasModel ( el , value )
890881 }
891882 }
892883 } else {
893884 // literal attribute
894- if ( process . env . NODE_ENV !== 'production' ) {
885+ if ( __DEV__ ) {
895886 const res = parseText ( value , delimiters )
896887 if ( res ) {
897888 warn (
@@ -942,12 +933,7 @@ function parseModifiers(name: string): Object | void {
942933function makeAttrsMap ( attrs : Array < Record < string , any > > ) : Record < string , any > {
943934 const map = { }
944935 for ( let i = 0 , l = attrs . length ; i < l ; i ++ ) {
945- if (
946- process . env . NODE_ENV !== 'production' &&
947- map [ attrs [ i ] . name ] &&
948- ! isIE &&
949- ! isEdge
950- ) {
936+ if ( __DEV__ && map [ attrs [ i ] . name ] && ! isIE && ! isEdge ) {
951937 warn ( 'duplicate attribute: ' + attrs [ i ] . name , attrs [ i ] )
952938 }
953939 map [ attrs [ i ] . name ] = attrs [ i ] . value
0 commit comments