.'
24 | )
25 | }
26 | }
27 | el.staticStyle = JSON.stringify(parseStyleText(staticStyle))
28 | }
29 |
30 | const styleBinding = getBindingAttr(el, 'style', false /* getStatic */)
31 | if (styleBinding) {
32 | el.styleBinding = styleBinding
33 | }
34 | }
35 |
36 | function genData (el: ASTElement): string {
37 | let data = ''
38 | if (el.staticStyle) {
39 | data += `staticStyle:${el.staticStyle},`
40 | }
41 | if (el.styleBinding) {
42 | data += `style:(${el.styleBinding}),`
43 | }
44 | return data
45 | }
46 |
47 | export default {
48 | staticKeys: ['staticStyle'],
49 | transformNode,
50 | genData
51 | }
52 |
--------------------------------------------------------------------------------
/带注释的Vue源码/vue/src/platforms/web/compiler/options.js:
--------------------------------------------------------------------------------
1 | /* @flow */
2 |
3 | import {
4 | isPreTag,
5 | mustUseProp,
6 | isReservedTag,
7 | getTagNamespace
8 | } from '../util/index'
9 |
10 | import modules from './modules/index'
11 | import directives from './directives/index'
12 | import { genStaticKeys } from 'shared/util'
13 | import { isUnaryTag, canBeLeftOpenTag } from './util'
14 |
15 | export const baseOptions: CompilerOptions = {
16 | expectHTML: true,
17 | modules,
18 | directives,
19 | isPreTag,
20 | isUnaryTag,
21 | mustUseProp,
22 | canBeLeftOpenTag,
23 | isReservedTag,
24 | getTagNamespace,
25 | staticKeys: genStaticKeys(modules)
26 | }
27 |
--------------------------------------------------------------------------------
/带注释的Vue源码/vue/src/platforms/web/compiler/util.js:
--------------------------------------------------------------------------------
1 | /* @flow */
2 |
3 | import { makeMap } from 'shared/util'
4 |
5 | export const isUnaryTag = makeMap(
6 | 'area,base,br,col,embed,frame,hr,img,input,isindex,keygen,' +
7 | 'link,meta,param,source,track,wbr'
8 | )
9 |
10 | // Elements that you can, intentionally, leave open
11 | // (and which close themselves)
12 | export const canBeLeftOpenTag = makeMap(
13 | 'colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr,source'
14 | )
15 |
16 | // HTML5 tags https://html.spec.whatwg.org/multipage/indices.html#elements-3
17 | // Phrasing Content https://html.spec.whatwg.org/multipage/dom.html#phrasing-content
18 | export const isNonPhrasingTag = makeMap(
19 | 'address,article,aside,base,blockquote,body,caption,col,colgroup,dd,' +
20 | 'details,dialog,div,dl,dt,fieldset,figcaption,figure,footer,form,' +
21 | 'h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,legend,li,menuitem,meta,' +
22 | 'optgroup,option,param,rp,rt,source,style,summary,tbody,td,tfoot,th,thead,' +
23 | 'title,tr,track'
24 | )
25 |
--------------------------------------------------------------------------------
/带注释的Vue源码/vue/src/platforms/web/entry-compiler.js:
--------------------------------------------------------------------------------
1 | /* @flow */
2 |
3 | export { parseComponent } from 'sfc/parser'
4 | export { compile, compileToFunctions } from './compiler/index'
5 | export { ssrCompile, ssrCompileToFunctions } from './server/compiler'
6 |
--------------------------------------------------------------------------------
/带注释的Vue源码/vue/src/platforms/web/entry-runtime.js:
--------------------------------------------------------------------------------
1 | /* @flow */
2 |
3 | import Vue from './runtime/index'
4 |
5 | export default Vue
6 |
--------------------------------------------------------------------------------
/带注释的Vue源码/vue/src/platforms/web/entry-server-basic-renderer.js:
--------------------------------------------------------------------------------
1 | /* @flow */
2 |
3 | import modules from './server/modules/index'
4 | import directives from './server/directives/index'
5 | import { isUnaryTag, canBeLeftOpenTag } from './compiler/util'
6 | import { createBasicRenderer } from 'server/create-basic-renderer'
7 |
8 | export default createBasicRenderer({
9 | modules,
10 | directives,
11 | isUnaryTag,
12 | canBeLeftOpenTag
13 | })
14 |
--------------------------------------------------------------------------------
/带注释的Vue源码/vue/src/platforms/web/entry-server-renderer.js:
--------------------------------------------------------------------------------
1 | /* @flow */
2 |
3 | process.env.VUE_ENV = 'server'
4 |
5 | import { extend } from 'shared/util'
6 | import modules from './server/modules/index'
7 | import baseDirectives from './server/directives/index'
8 | import { isUnaryTag, canBeLeftOpenTag } from './compiler/util'
9 |
10 | import { createRenderer as _createRenderer } from 'server/create-renderer'
11 | import { createBundleRendererCreator } from 'server/bundle-renderer/create-bundle-renderer'
12 |
13 | export function createRenderer (options?: Object = {}): {
14 | renderToString: Function,
15 | renderToStream: Function
16 | } {
17 | return _createRenderer(extend(extend({}, options), {
18 | isUnaryTag,
19 | canBeLeftOpenTag,
20 | modules,
21 | // user can provide server-side implementations for custom directives
22 | // when creating the renderer.
23 | directives: extend(baseDirectives, options.directives)
24 | }))
25 | }
26 |
27 | export const createBundleRenderer = createBundleRendererCreator(createRenderer)
28 |
--------------------------------------------------------------------------------
/带注释的Vue源码/vue/src/platforms/web/runtime/class-util.js:
--------------------------------------------------------------------------------
1 | /* @flow */
2 |
3 | /**
4 | * Add class with compatibility for SVG since classList is not supported on
5 | * SVG elements in IE
6 | */
7 | export function addClass (el: HTMLElement, cls: ?string) {
8 | /* istanbul ignore if */
9 | if (!cls || !(cls = cls.trim())) {
10 | return
11 | }
12 |
13 | /* istanbul ignore else */
14 | if (el.classList) {
15 | if (cls.indexOf(' ') > -1) {
16 | cls.split(/\s+/).forEach(c => el.classList.add(c))
17 | } else {
18 | el.classList.add(cls)
19 | }
20 | } else {
21 | const cur = ` ${el.getAttribute('class') || ''} `
22 | if (cur.indexOf(' ' + cls + ' ') < 0) {
23 | el.setAttribute('class', (cur + cls).trim())
24 | }
25 | }
26 | }
27 |
28 | /**
29 | * Remove class with compatibility for SVG since classList is not supported on
30 | * SVG elements in IE
31 | */
32 | export function removeClass (el: HTMLElement, cls: ?string) {
33 | /* istanbul ignore if */
34 | if (!cls || !(cls = cls.trim())) {
35 | return
36 | }
37 |
38 | /* istanbul ignore else */
39 | if (el.classList) {
40 | if (cls.indexOf(' ') > -1) {
41 | cls.split(/\s+/).forEach(c => el.classList.remove(c))
42 | } else {
43 | el.classList.remove(cls)
44 | }
45 | if (!el.classList.length) {
46 | el.removeAttribute('class')
47 | }
48 | } else {
49 | let cur = ` ${el.getAttribute('class') || ''} `
50 | const tar = ' ' + cls + ' '
51 | while (cur.indexOf(tar) >= 0) {
52 | cur = cur.replace(tar, ' ')
53 | }
54 | cur = cur.trim()
55 | if (cur) {
56 | el.setAttribute('class', cur)
57 | } else {
58 | el.removeAttribute('class')
59 | }
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/带注释的Vue源码/vue/src/platforms/web/runtime/components/index.js:
--------------------------------------------------------------------------------
1 | import Transition from './transition'
2 | import TransitionGroup from './transition-group'
3 |
4 | export default {
5 | Transition,
6 | TransitionGroup
7 | }
8 |
--------------------------------------------------------------------------------
/带注释的Vue源码/vue/src/platforms/web/runtime/directives/index.js:
--------------------------------------------------------------------------------
1 | import model from './model'
2 | import show from './show'
3 |
4 | export default {
5 | model,
6 | show
7 | }
8 |
--------------------------------------------------------------------------------
/带注释的Vue源码/vue/src/platforms/web/runtime/modules/class.js:
--------------------------------------------------------------------------------
1 | /* @flow */
2 |
3 | import {
4 | isDef,
5 | isUndef
6 | } from 'shared/util'
7 |
8 | import {
9 | concat,
10 | stringifyClass,
11 | genClassForVnode
12 | } from 'web/util/index'
13 |
14 | function updateClass (oldVnode: any, vnode: any) {
15 | const el = vnode.elm
16 | const data: VNodeData = vnode.data
17 | const oldData: VNodeData = oldVnode.data
18 | if (
19 | isUndef(data.staticClass) &&
20 | isUndef(data.class) && (
21 | isUndef(oldData) || (
22 | isUndef(oldData.staticClass) &&
23 | isUndef(oldData.class)
24 | )
25 | )
26 | ) {
27 | return
28 | }
29 |
30 | let cls = genClassForVnode(vnode)
31 |
32 | // handle transition classes
33 | const transitionClass = el._transitionClasses
34 | if (isDef(transitionClass)) {
35 | cls = concat(cls, stringifyClass(transitionClass))
36 | }
37 |
38 | // set the class
39 | if (cls !== el._prevClass) {
40 | el.setAttribute('class', cls)
41 | el._prevClass = cls
42 | }
43 | }
44 |
45 | export default {
46 | create: updateClass,
47 | update: updateClass
48 | }
49 |
--------------------------------------------------------------------------------
/带注释的Vue源码/vue/src/platforms/web/runtime/modules/index.js:
--------------------------------------------------------------------------------
1 | import attrs from './attrs'
2 | import klass from './class'
3 | import events from './events'
4 | import domProps from './dom-props'
5 | import style from './style'
6 | import transition from './transition'
7 |
8 | export default [
9 | attrs,
10 | klass,
11 | events,
12 | domProps,
13 | style,
14 | transition
15 | ]
16 |
--------------------------------------------------------------------------------
/带注释的Vue源码/vue/src/platforms/web/runtime/node-ops.js:
--------------------------------------------------------------------------------
1 | /* @flow */
2 |
3 | import { namespaceMap } from 'web/util/index'
4 |
5 | export function createElement (tagName: string, vnode: VNode): Element {
6 | const elm = document.createElement(tagName)
7 | if (tagName !== 'select') {
8 | return elm
9 | }
10 | // false or null will remove the attribute but undefined will not
11 | if (vnode.data && vnode.data.attrs && vnode.data.attrs.multiple !== undefined) {
12 | elm.setAttribute('multiple', 'multiple')
13 | }
14 | return elm
15 | }
16 |
17 | export function createElementNS (namespace: string, tagName: string): Element {
18 | return document.createElementNS(namespaceMap[namespace], tagName)
19 | }
20 |
21 | export function createTextNode (text: string): Text {
22 | return document.createTextNode(text)
23 | }
24 |
25 | export function createComment (text: string): Comment {
26 | return document.createComment(text)
27 | }
28 |
29 | export function insertBefore (parentNode: Node, newNode: Node, referenceNode: Node) {
30 | parentNode.insertBefore(newNode, referenceNode)
31 | }
32 |
33 | export function removeChild (node: Node, child: Node) {
34 | node.removeChild(child)
35 | }
36 |
37 | export function appendChild (node: Node, child: Node) {
38 | node.appendChild(child)
39 | }
40 |
41 | export function parentNode (node: Node): ?Node {
42 | return node.parentNode
43 | }
44 |
45 | export function nextSibling (node: Node): ?Node {
46 | return node.nextSibling
47 | }
48 |
49 | export function tagName (node: Element): string {
50 | return node.tagName
51 | }
52 |
53 | export function setTextContent (node: Node, text: string) {
54 | node.textContent = text
55 | }
56 |
57 | export function setStyleScope (node: Element, scopeId: string) {
58 | node.setAttribute(scopeId, '')
59 | }
60 |
--------------------------------------------------------------------------------
/带注释的Vue源码/vue/src/platforms/web/runtime/patch.js:
--------------------------------------------------------------------------------
1 | /* @flow */
2 |
3 | import * as nodeOps from 'web/runtime/node-ops'
4 | import { createPatchFunction } from 'core/vdom/patch'
5 | import baseModules from 'core/vdom/modules/index'
6 | import platformModules from 'web/runtime/modules/index'
7 |
8 | // the directive module should be applied last, after all
9 | // built-in modules have been applied.
10 | const modules = platformModules.concat(baseModules)
11 |
12 | export const patch: Function = createPatchFunction({ nodeOps, modules })
13 |
--------------------------------------------------------------------------------
/带注释的Vue源码/vue/src/platforms/web/server/compiler.js:
--------------------------------------------------------------------------------
1 | /* @flow */
2 |
3 | import { baseOptions } from '../compiler/options'
4 | import { createCompiler } from 'server/optimizing-compiler/index'
5 |
6 | const { compile, compileToFunctions } = createCompiler(baseOptions)
7 |
8 | export {
9 | compile as ssrCompile,
10 | compileToFunctions as ssrCompileToFunctions
11 | }
12 |
--------------------------------------------------------------------------------
/带注释的Vue源码/vue/src/platforms/web/server/directives/index.js:
--------------------------------------------------------------------------------
1 | import show from './show'
2 | import model from './model'
3 |
4 | export default {
5 | show,
6 | model
7 | }
8 |
--------------------------------------------------------------------------------
/带注释的Vue源码/vue/src/platforms/web/server/directives/model.js:
--------------------------------------------------------------------------------
1 | /* @flow */
2 |
3 | import { looseEqual, looseIndexOf } from 'shared/util'
4 |
5 | // this is only applied for