Просмотр исходного кода

coverage (passive not supported in PhantomJS)

Evan You 9 лет назад
Родитель
Сommit
08d37c0e8c
4 измененных файлов с 15 добавлено и 6 удалено
  1. 8 3
      src/compiler/helpers.js
  2. 2 2
      src/compiler/parser/index.js
  3. 1 0
      src/core/instance/inject.js
  4. 4 1
      src/core/util/env.js

+ 8 - 3
src/compiler/helpers.js

@@ -1,6 +1,5 @@
 /* @flow */
 
-import { warn } from 'core/util/index'
 import { parseFilters } from './parser/filter-parser'
 
 export function baseWarn (msg: string) {
@@ -40,10 +39,15 @@ export function addHandler (
   name: string,
   value: string,
   modifiers: ?ASTModifiers,
-  important: ?boolean
+  important?: boolean,
+  warn?: Function
 ) {
   // warn prevent and passive modifier
-  if (process.env.NODE_ENV !== 'production' && modifiers && modifiers.prevent && modifiers.passive) {
+  /* istanbul ignore if */
+  if (
+    process.env.NODE_ENV !== 'production' && warn &&
+    modifiers && modifiers.prevent && modifiers.passive
+  ) {
     warn(
       'passive and prevent can\'t be used together. ' +
       'Passive handler can\'t prevent default event.'
@@ -58,6 +62,7 @@ export function addHandler (
     delete modifiers.once
     name = '~' + name // mark the event as once
   }
+  /* istanbul ignore if */
   if (modifiers && modifiers.passive) {
     delete modifiers.passive
     name = '&' + name // mark the event as passive

+ 2 - 2
src/compiler/parser/index.js

@@ -31,7 +31,7 @@ const modifierRE = /\.[^.]+/g
 const decodeHTMLCached = cached(decode)
 
 // configurable state
-let warn
+export let warn
 let delimiters
 let transforms
 let preTransforms
@@ -478,7 +478,7 @@ function processAttrs (el) {
         }
       } else if (onRE.test(name)) { // v-on
         name = name.replace(onRE, '')
-        addHandler(el, name, value, modifiers)
+        addHandler(el, name, value, modifiers, false, warn)
       } else { // normal directives
         name = name.replace(dirRE, '')
         // parse arg

+ 1 - 0
src/core/instance/inject.js

@@ -17,6 +17,7 @@ export function initInjections (vm: Component) {
   const result = resolveInject(vm.$options.inject, vm)
   if (result) {
     Object.keys(result).forEach(key => {
+      /* istanbul ignore else */
       if (process.env.NODE_ENV !== 'production') {
         defineReactive(vm, key, result[key], () => {
           warn(

+ 4 - 1
src/core/util/env.js

@@ -21,7 +21,10 @@ if (inBrowser) {
   try {
     const opts = {}
     Object.defineProperty(opts, 'passive', ({
-      get: function () { supportsPassive = true }
+      get () {
+        /* istanbul ignore next */
+        supportsPassive = true
+      }
     } : Object)) // https://github.com/facebook/flow/issues/285
     window.addEventListener('test-passive', null, opts)
   } catch (e) {}