/* @flow */ import { genHandlers } from './events' import { baseWarn, pluckModuleFunction } from '../helpers' import baseDirectives from '../directives/index' import { camelize } from 'shared/util' // configurable state let warn let transforms let da…
/** * Not type-checking this file because it's mostly vendor code. */ /*! * HTML Parser By John Resig (ejohn.org) * Modified by Juriy "kangax" Zaytsev * Original code by Erik Arvidsson, Mozilla Public License * http://erik.eae.net/simplehtmlpars…
/* @flow */ import { parseFilters } from './parser/filter-parser' export function baseWarn (msg: string) { console.error(`[Vue parser]: ${msg}`) } export function pluckModuleFunction ( modules: ?Array<Object>, key: string ): Array<Function> {…
/* @flow */ const fnExpRE = /^\s*([\w$_]+|\([^)]*?\))\s*=>|^function\s*\(/ const simplePathRE = /^\s*[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\['.*?']|\[".*?"]|\[\d+]|\[[A-Za-z_$][\w$]*])*\s*$/ // keyCode aliases const keyCodes = { esc: 27, tab:…
/* @flow */ export function parseFilters (exp: string): string { let inSingle = false let inDouble = false let inTemplateString = false let inRegex = false let curly = 0 let square = 0 let paren = 0 let lastFilterIndex = 0 let c, prev, i, expression,…
/* @flow */ import { cached } from 'shared/util' import { parseFilters } from './filter-parser' //找到{{abc}}这样的 const defaultTagRE = /\{\{((?:.|\n)+?)\}\}/g //.+的意义是最小匹配, 找到符合的马上结束 //正则的元字符 ^ $ . * + ? = ! : | \ / ( ) [ ] { }const regexEscapeRE = /[-.…
/* @flow */ // Object.freeze 使得这个对象不能增加属性, 修改属性, 这样就保证了这个对象在任何时候都是空的 export const emptyObject = Object.freeze({}) /** * Check if a string starts with $ or _ ascii unicode 的区别 charcodeAt是一个字符的 unicode编码, 但是像 0x24 (代表的是 $ ) 0x5f (代表的是 _ ) 因为是字符, 先存着asc…
/* @flow */ /* globals MutationObserver */ import { noop } from 'shared/util' // can we use __proto__? 有些浏览器不能让你明目张胆的使用 __proto__ export const hasProto = '__proto__' in {} // Browser environment sniffing 这里作者不太严谨, 直接用 navigator.userAget 判断浏览器 //利用 wi…
/* @flow */ /** * Convert a value to a string that is actually rendered. { .. } [ .. ] 2 => '' */ export function _toString (val: any): string { return val == null ? '' : typeof val === 'object' ? JSON.stringify(val, null, 2) //2 是控制字符串系列化后的空格为2 : St…
/* @flow */ import { warn, nextTick, toNumber, _toString, looseEqual, emptyObject, handleError, looseIndexOf } from '../util/index' import VNode, { cloneVNodes, createTextVNode, createEmptyVNode } from '../vdom/vnode' import { createElement } from '.…
/* @flow */ import { updateListeners } from '../vdom/helpers/index' import { toArray, tip, hyphenate, formatComponentName } from '../util/index' export function initEvents (vm: Component) { vm._events = Object.create(null) vm._hasHookEvent = false //…
/* @flow */ import config from '../config' import { initProxy } from './proxy' import { initState } from './state' import { initRender } from './render' import { initEvents } from './events' import { mark, measure } from '../util/perf' import { initL…
import { initMixin } from './init' import { stateMixin } from './state' import { renderMixin } from './render' import { eventsMixin } from './events' import { lifecycleMixin } from './lifecycle' import { warn } from '../util/index' function Vue (opti…
/* @flow */ import Dep from '../observer/dep' import Watcher from '../observer/watcher' import { set, del, observe, observerState, defineReactive } from '../observer/index' import { warn, bind, noop, hasOwn, isReserved, handleError, validateProp, isP…
/* @flow */ import config from '../config' import Watcher from '../observer/watcher' import { mark, measure } from '../util/perf' import { createEmptyVNode } from '../vdom/vnode' import { observerState } from '../observer/index' import { updateCompon…
/* @flow */ import Vue from '../instance/index' import config from '../config' import { warn } from './debug' import { set } from '../observer/index' import { extend, isPlainObject, hasOwn, camelize, capitalize, isBuiltInTag } from 'shared/util' /**…
import config from '../config' import { noop } from 'shared/util' let warn = noop let tip = noop let formatComponentName //如果是在开发环境 或者 在测试环境 if (process.env.NODE_ENV !== 'production') { //如果 有 window.console, 这里用typeof判断, 是因为如果用 if(window.console) //…
参考 vue 2.2.6版本 /* @flow */ //引入订阅者模式 import Dep from './dep' import { arrayMethods } from './array' import { def, isObject, isPlainObject, hasProto, hasOwn, warn, isServerRendering } from '../util/index' const arrayKeys = Object.getOwnPropertyNames(a…
/* @flow */ let decoder export function decode (html: string): string { decoder = decoder || document.createElement('div') decoder.innerHTML = html return decoder.textContent }…
/* @flow */ import { callHook } from 'core/instance/lifecycle' import { getFirstComponentChild } from 'core/vdom/helpers/index' const patternTypes = [String, RegExp] function matches (pattern: string | RegExp, name: string): boolean { if (typeof patt…
/* @flow */ import { hasSymbol } from 'core/util/env' import { warn } from '../util/index' import { defineReactive } from '../observer/index' export function initProvide (vm: Component) { const provide = vm.$options.provide if (provide) { // 计算proved…
/* not type checking this file because flow doesn't play well with Proxy */ import config from 'core/config' import { warn, makeMap } from '../util/index' let initProxy if (process.env.NODE_ENV !== 'production') { //一些能使用的全局变量 const allowedGlobals =…
/* @flow */ import type Watcher from './watcher' import config from '../config' import { callHook } from '../instance/lifecycle' import { warn, nextTick, devtools } from '../util/index' const queue: Array<Watcher> = [] let has: { [key: number]: ?tru…
/* * not type checking this file because flow doesn't play well with * dynamically accessing methods on Array prototype */ import { def } from '../util/index' const arrayProto = Array.prototype // Object.create 如果传入的是数组, 那么这个数组会被封装成一个对象,这个对象作为目标对象的__…
/* @flow */ import { hasOwn, isObject, isPlainObject, capitalize, hyphenate } from 'shared/util' import { observe, observerState } from '../observer/index' import { warn } from './debug' type PropOptions = { type: Function | Array<Function> | null,…
import { inBrowser } from './env' export let mark export let measure if (process.env.NODE_ENV !== 'production') { //如果在浏览器环境, const perf = inBrowser &&window.performance /* istanbul ignore if */ if ( perf && perf.mark && perf.measu…
import config from '../config' import { warn } from './debug' import { inBrowser } from './env' // 这个方法先调用用户配置的 erroHandler 方法输出, 如果没有配置, 在开发测试环境调用warn输出, 在非浏览器环境用 throw抛出错误 export function handleError (err, vm, info) { if (config.errorHandler) { con…
/* @flow */ import { queueWatcher } from './scheduler' import Dep, { pushTarget, popTarget } from './dep' import { warn, remove, isObject, parsePath, _Set as Set, handleError } from '../util/index' let uid = 0 /** * A watcher parses an expression, co…
/* @flow */ import type Watcher from './watcher' import { remove } from '../util/index' let uid = 0 /** * A dep is an observable that can have multiple * directives subscribing to it. 一个订阅模式 可以有多个指令去订阅他 */ export default class Dep { static target: ?W…
#js再学习笔记 ##基本 1.js严格区分大小写   2.js末尾的分号可加,也可不加   3.六种数据类型(使用typeof来检验数据的类型) `typeof` - undefined: `var name;` ------就是已定义未赋值或者未定义而使用**针对变量来说**,占据一个变量的位置而不使用. - boolean-------布尔类型 - string: `var name="zhangsan"; var englishname='tom';` -----字符串类型,单…