nav tabs on admin dashboard
This commit is contained in:
+1
-1
@@ -4,6 +4,6 @@ import { addProp } from 'compiler/helpers'
|
||||
|
||||
export default function html (el: ASTElement, dir: ASTDirective) {
|
||||
if (dir.value) {
|
||||
addProp(el, 'innerHTML', `_s(${dir.value})`)
|
||||
addProp(el, 'innerHTML', `_s(${dir.value})`, dir)
|
||||
}
|
||||
}
|
||||
|
||||
+6
-3
@@ -28,7 +28,8 @@ export default function model (
|
||||
if (tag === 'input' && type === 'file') {
|
||||
warn(
|
||||
`<${el.tag} v-model="${value}" type="file">:\n` +
|
||||
`File inputs are read only. Use a v-on:change listener instead.`
|
||||
`File inputs are read only. Use a v-on:change listener instead.`,
|
||||
el.rawAttrsMap['v-model']
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -54,7 +55,8 @@ export default function model (
|
||||
`<${el.tag} v-model="${value}">: ` +
|
||||
`v-model is not supported on this element type. ` +
|
||||
'If you are working with contenteditable, it\'s recommended to ' +
|
||||
'wrap a library dedicated for that purpose inside a custom component.'
|
||||
'wrap a library dedicated for that purpose inside a custom component.',
|
||||
el.rawAttrsMap['v-model']
|
||||
)
|
||||
}
|
||||
|
||||
@@ -138,7 +140,8 @@ function genDefaultModel (
|
||||
const binding = el.attrsMap['v-bind:value'] ? 'v-bind:value' : ':value'
|
||||
warn(
|
||||
`${binding}="${value}" conflicts with v-model on the same element ` +
|
||||
'because the latter already expands to a value binding internally'
|
||||
'because the latter already expands to a value binding internally',
|
||||
el.rawAttrsMap[binding]
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,6 +4,6 @@ import { addProp } from 'compiler/helpers'
|
||||
|
||||
export default function text (el: ASTElement, dir: ASTDirective) {
|
||||
if (dir.value) {
|
||||
addProp(el, 'textContent', `_s(${dir.value})`)
|
||||
addProp(el, 'textContent', `_s(${dir.value})`, dir)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -17,7 +17,8 @@ function transformNode (el: ASTElement, options: CompilerOptions) {
|
||||
`class="${staticClass}": ` +
|
||||
'Interpolation inside attributes has been removed. ' +
|
||||
'Use v-bind or the colon shorthand instead. For example, ' +
|
||||
'instead of <div class="{{ val }}">, use <div :class="val">.'
|
||||
'instead of <div class="{{ val }}">, use <div :class="val">.',
|
||||
el.rawAttrsMap['class']
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -20,7 +20,8 @@ function transformNode (el: ASTElement, options: CompilerOptions) {
|
||||
`style="${staticStyle}": ` +
|
||||
'Interpolation inside attributes has been removed. ' +
|
||||
'Use v-bind or the colon shorthand instead. For example, ' +
|
||||
'instead of <div style="{{ val }}">, use <div :style="val">.'
|
||||
'instead of <div style="{{ val }}">, use <div :style="val">.',
|
||||
el.rawAttrsMap['style']
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -3,3 +3,4 @@
|
||||
export { parseComponent } from 'sfc/parser'
|
||||
export { compile, compileToFunctions } from './compiler/index'
|
||||
export { ssrCompile, ssrCompileToFunctions } from './server/compiler'
|
||||
export { generateCodeFrame } from 'compiler/codeframe'
|
||||
|
||||
+1
@@ -63,6 +63,7 @@ Vue.prototype.$mount = function (
|
||||
}
|
||||
|
||||
const { render, staticRenderFns } = compileToFunctions(template, {
|
||||
outputSourceRange: process.env.NODE_ENV !== 'production',
|
||||
shouldDecodeNewlines,
|
||||
shouldDecodeNewlinesForHref,
|
||||
delimiters: options.delimiters,
|
||||
|
||||
+4
-2
@@ -1,5 +1,7 @@
|
||||
/* @flow */
|
||||
|
||||
const whitespaceRE = /\s+/
|
||||
|
||||
/**
|
||||
* Add class with compatibility for SVG since classList is not supported on
|
||||
* SVG elements in IE
|
||||
@@ -13,7 +15,7 @@ export function addClass (el: HTMLElement, cls: ?string) {
|
||||
/* istanbul ignore else */
|
||||
if (el.classList) {
|
||||
if (cls.indexOf(' ') > -1) {
|
||||
cls.split(/\s+/).forEach(c => el.classList.add(c))
|
||||
cls.split(whitespaceRE).forEach(c => el.classList.add(c))
|
||||
} else {
|
||||
el.classList.add(cls)
|
||||
}
|
||||
@@ -38,7 +40,7 @@ export function removeClass (el: HTMLElement, cls: ?string) {
|
||||
/* istanbul ignore else */
|
||||
if (el.classList) {
|
||||
if (cls.indexOf(' ') > -1) {
|
||||
cls.split(/\s+/).forEach(c => el.classList.remove(c))
|
||||
cls.split(whitespaceRE).forEach(c => el.classList.remove(c))
|
||||
} else {
|
||||
el.classList.remove(cls)
|
||||
}
|
||||
|
||||
+23
-13
@@ -14,6 +14,7 @@
|
||||
import { warn, extend } from 'core/util/index'
|
||||
import { addClass, removeClass } from '../class-util'
|
||||
import { transitionProps, extractTransitionData } from './transition'
|
||||
import { setActiveInstance } from 'core/instance/lifecycle'
|
||||
|
||||
import {
|
||||
hasTransition,
|
||||
@@ -33,6 +34,23 @@ delete props.mode
|
||||
export default {
|
||||
props,
|
||||
|
||||
beforeMount () {
|
||||
const update = this._update
|
||||
this._update = (vnode, hydrating) => {
|
||||
const restoreActiveInstance = setActiveInstance(this)
|
||||
// force removing pass
|
||||
this.__patch__(
|
||||
this._vnode,
|
||||
this.kept,
|
||||
false, // hydrating
|
||||
true // removeOnly (!important, avoids unnecessary moves)
|
||||
)
|
||||
this._vnode = this.kept
|
||||
restoreActiveInstance()
|
||||
update.call(this, vnode, hydrating)
|
||||
}
|
||||
},
|
||||
|
||||
render (h: Function) {
|
||||
const tag: string = this.tag || this.$vnode.data.tag || 'span'
|
||||
const map: Object = Object.create(null)
|
||||
@@ -76,17 +94,6 @@ export default {
|
||||
return h(tag, null, children)
|
||||
},
|
||||
|
||||
beforeUpdate () {
|
||||
// force removing pass
|
||||
this.__patch__(
|
||||
this._vnode,
|
||||
this.kept,
|
||||
false, // hydrating
|
||||
true // removeOnly (!important, avoids unnecessary moves)
|
||||
)
|
||||
this._vnode = this.kept
|
||||
},
|
||||
|
||||
updated () {
|
||||
const children: Array<VNode> = this.prevChildren
|
||||
const moveClass: string = this.moveClass || ((this.name || 'v') + '-move')
|
||||
@@ -107,11 +114,14 @@ export default {
|
||||
|
||||
children.forEach((c: VNode) => {
|
||||
if (c.data.moved) {
|
||||
var el: any = c.elm
|
||||
var s: any = el.style
|
||||
const el: any = c.elm
|
||||
const s: any = el.style
|
||||
addTransitionClass(el, moveClass)
|
||||
s.transform = s.WebkitTransform = s.transitionDuration = ''
|
||||
el.addEventListener(transitionEndEvent, el._moveCb = function cb (e) {
|
||||
if (e && e.target !== el) {
|
||||
return
|
||||
}
|
||||
if (!e || /transform$/.test(e.propertyName)) {
|
||||
el.removeEventListener(transitionEndEvent, cb)
|
||||
el._moveCb = null
|
||||
|
||||
+6
-2
@@ -76,6 +76,10 @@ function isSameChild (child: VNode, oldChild: VNode): boolean {
|
||||
return oldChild.key === child.key && oldChild.tag === child.tag
|
||||
}
|
||||
|
||||
const isNotTextNode = (c: VNode) => c.tag || isAsyncPlaceholder(c)
|
||||
|
||||
const isVShowDirective = d => d.name === 'show'
|
||||
|
||||
export default {
|
||||
name: 'transition',
|
||||
props: transitionProps,
|
||||
@@ -88,7 +92,7 @@ export default {
|
||||
}
|
||||
|
||||
// filter out text nodes (possible whitespaces)
|
||||
children = children.filter((c: VNode) => c.tag || isAsyncPlaceholder(c))
|
||||
children = children.filter(isNotTextNode)
|
||||
/* istanbul ignore if */
|
||||
if (!children.length) {
|
||||
return
|
||||
@@ -153,7 +157,7 @@ export default {
|
||||
|
||||
// mark v-show
|
||||
// so that the transition module can hand over the control to the directive
|
||||
if (child.data.directives && child.data.directives.some(d => d.name === 'show')) {
|
||||
if (child.data.directives && child.data.directives.some(isVShowDirective)) {
|
||||
child.data.show = true
|
||||
}
|
||||
|
||||
|
||||
+2
-3
@@ -4,7 +4,7 @@ import Vue from 'core/index'
|
||||
import config from 'core/config'
|
||||
import { extend, noop } from 'shared/util'
|
||||
import { mountComponent } from 'core/instance/lifecycle'
|
||||
import { devtools, inBrowser, isChrome } from 'core/util/index'
|
||||
import { devtools, inBrowser } from 'core/util/index'
|
||||
|
||||
import {
|
||||
query,
|
||||
@@ -51,8 +51,7 @@ if (inBrowser) {
|
||||
devtools.emit('init', Vue)
|
||||
} else if (
|
||||
process.env.NODE_ENV !== 'production' &&
|
||||
process.env.NODE_ENV !== 'test' &&
|
||||
isChrome
|
||||
process.env.NODE_ENV !== 'test'
|
||||
) {
|
||||
console[console.info ? 'info' : 'log'](
|
||||
'Download the Vue Devtools extension for a better development experience:\n' +
|
||||
|
||||
+4
-3
@@ -14,7 +14,8 @@ import {
|
||||
getXlinkProp,
|
||||
isBooleanAttr,
|
||||
isEnumeratedAttr,
|
||||
isFalsyAttrValue
|
||||
isFalsyAttrValue,
|
||||
convertEnumeratedValue
|
||||
} from 'web/util/index'
|
||||
|
||||
function updateAttrs (oldVnode: VNodeWithData, vnode: VNodeWithData) {
|
||||
@@ -75,7 +76,7 @@ function setAttr (el: Element, key: string, value: any) {
|
||||
el.setAttribute(key, value)
|
||||
}
|
||||
} else if (isEnumeratedAttr(key)) {
|
||||
el.setAttribute(key, isFalsyAttrValue(value) || value === 'false' ? 'false' : 'true')
|
||||
el.setAttribute(key, convertEnumeratedValue(key, value))
|
||||
} else if (isXlink(key)) {
|
||||
if (isFalsyAttrValue(value)) {
|
||||
el.removeAttributeNS(xlinkNS, getXlinkProp(key))
|
||||
@@ -98,7 +99,7 @@ function baseSetAttr (el, key, value) {
|
||||
if (
|
||||
isIE && !isIE9 &&
|
||||
el.tagName === 'TEXTAREA' &&
|
||||
key === 'placeholder' && !el.__ieph
|
||||
key === 'placeholder' && value !== '' && !el.__ieph
|
||||
) {
|
||||
const blocker = e => {
|
||||
e.stopImmediatePropagation()
|
||||
|
||||
+27
-7
@@ -1,6 +1,9 @@
|
||||
/* @flow */
|
||||
|
||||
import { isDef, isUndef, extend, toNumber } from 'shared/util'
|
||||
import { isSVG } from 'web/util/index'
|
||||
|
||||
let svgContainer
|
||||
|
||||
function updateDOMProps (oldVnode: VNodeWithData, vnode: VNodeWithData) {
|
||||
if (isUndef(oldVnode.data.domProps) && isUndef(vnode.data.domProps)) {
|
||||
@@ -35,7 +38,7 @@ function updateDOMProps (oldVnode: VNodeWithData, vnode: VNodeWithData) {
|
||||
}
|
||||
}
|
||||
|
||||
if (key === 'value') {
|
||||
if (key === 'value' && elm.tagName !== 'PROGRESS') {
|
||||
// store value as _value as well since
|
||||
// non-string values will be stringified
|
||||
elm._value = cur
|
||||
@@ -44,8 +47,29 @@ function updateDOMProps (oldVnode: VNodeWithData, vnode: VNodeWithData) {
|
||||
if (shouldUpdateValue(elm, strCur)) {
|
||||
elm.value = strCur
|
||||
}
|
||||
} else {
|
||||
elm[key] = cur
|
||||
} else if (key === 'innerHTML' && isSVG(elm.tagName) && isUndef(elm.innerHTML)) {
|
||||
// IE doesn't support innerHTML for SVG elements
|
||||
svgContainer = svgContainer || document.createElement('div')
|
||||
svgContainer.innerHTML = `<svg>${cur}</svg>`
|
||||
const svg = svgContainer.firstChild
|
||||
while (elm.firstChild) {
|
||||
elm.removeChild(elm.firstChild)
|
||||
}
|
||||
while (svg.firstChild) {
|
||||
elm.appendChild(svg.firstChild)
|
||||
}
|
||||
} else if (
|
||||
// skip the update if old and new VDOM state is the same.
|
||||
// `value` is handled separately because the DOM value may be temporarily
|
||||
// out of sync with VDOM state due to focus, composition and modifiers.
|
||||
// This #4521 by skipping the unnecesarry `checked` update.
|
||||
cur !== oldProps[key]
|
||||
) {
|
||||
// some property updates can throw
|
||||
// e.g. `value` on <progress> w/ non-finite value
|
||||
try {
|
||||
elm[key] = cur
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,10 +99,6 @@ function isDirtyWithModifiers (elm: any, newVal: string): boolean {
|
||||
const value = elm.value
|
||||
const modifiers = elm._vModifiers // injected by v-model runtime
|
||||
if (isDef(modifiers)) {
|
||||
if (modifiers.lazy) {
|
||||
// inputs with lazy should only be updated when not in focus
|
||||
return false
|
||||
}
|
||||
if (modifiers.number) {
|
||||
return toNumber(value) !== toNumber(newVal)
|
||||
}
|
||||
|
||||
+42
-11
@@ -2,8 +2,9 @@
|
||||
|
||||
import { isDef, isUndef } from 'shared/util'
|
||||
import { updateListeners } from 'core/vdom/helpers/index'
|
||||
import { withMacroTask, isIE, supportsPassive } from 'core/util/index'
|
||||
import { isIE, isFF, supportsPassive, isUsingMicroTask } from 'core/util/index'
|
||||
import { RANGE_TOKEN, CHECKBOX_RADIO_TOKEN } from 'web/compiler/directives/model'
|
||||
import { currentFlushTimestamp } from 'core/observer/scheduler'
|
||||
|
||||
// normalize v-model event tokens that can only be determined at runtime.
|
||||
// it's important to place the event as the first in the array because
|
||||
@@ -28,7 +29,7 @@ function normalizeEvents (on) {
|
||||
|
||||
let target: any
|
||||
|
||||
function createOnceHandler (handler, event, capture) {
|
||||
function createOnceHandler (event, handler, capture) {
|
||||
const _target = target // save current target element in closure
|
||||
return function onceHandler () {
|
||||
const res = handler.apply(null, arguments)
|
||||
@@ -38,17 +39,47 @@ function createOnceHandler (handler, event, capture) {
|
||||
}
|
||||
}
|
||||
|
||||
// #9446: Firefox <= 53 (in particular, ESR 52) has incorrect Event.timeStamp
|
||||
// implementation and does not fire microtasks in between event propagation, so
|
||||
// safe to exclude.
|
||||
const useMicrotaskFix = isUsingMicroTask && !(isFF && Number(isFF[1]) <= 53)
|
||||
|
||||
function add (
|
||||
event: string,
|
||||
name: string,
|
||||
handler: Function,
|
||||
once: boolean,
|
||||
capture: boolean,
|
||||
passive: boolean
|
||||
) {
|
||||
handler = withMacroTask(handler)
|
||||
if (once) handler = createOnceHandler(handler, event, capture)
|
||||
// async edge case #6566: inner click event triggers patch, event handler
|
||||
// attached to outer element during patch, and triggered again. This
|
||||
// happens because browsers fire microtask ticks between event propagation.
|
||||
// the solution is simple: we save the timestamp when a handler is attached,
|
||||
// and the handler would only fire if the event passed to it was fired
|
||||
// AFTER it was attached.
|
||||
if (useMicrotaskFix) {
|
||||
const attachedTimestamp = currentFlushTimestamp
|
||||
const original = handler
|
||||
handler = original._wrapper = function (e) {
|
||||
if (
|
||||
// no bubbling, should always fire.
|
||||
// this is just a safety net in case event.timeStamp is unreliable in
|
||||
// certain weird environments...
|
||||
e.target === e.currentTarget ||
|
||||
// event is fired after handler attachment
|
||||
e.timeStamp >= attachedTimestamp ||
|
||||
// #9462 bail for iOS 9 bug: event.timeStamp is 0 after history.pushState
|
||||
e.timeStamp === 0 ||
|
||||
// #9448 bail if event is fired in another document in a multi-page
|
||||
// electron/nw.js app, since event.timeStamp will be using a different
|
||||
// starting reference
|
||||
e.target.ownerDocument !== document
|
||||
) {
|
||||
return original.apply(this, arguments)
|
||||
}
|
||||
}
|
||||
}
|
||||
target.addEventListener(
|
||||
event,
|
||||
name,
|
||||
handler,
|
||||
supportsPassive
|
||||
? { capture, passive }
|
||||
@@ -57,14 +88,14 @@ function add (
|
||||
}
|
||||
|
||||
function remove (
|
||||
event: string,
|
||||
name: string,
|
||||
handler: Function,
|
||||
capture: boolean,
|
||||
_target?: HTMLElement
|
||||
) {
|
||||
(_target || target).removeEventListener(
|
||||
event,
|
||||
handler._withTask || handler,
|
||||
name,
|
||||
handler._wrapper || handler,
|
||||
capture
|
||||
)
|
||||
}
|
||||
@@ -77,7 +108,7 @@ function updateDOMListeners (oldVnode: VNodeWithData, vnode: VNodeWithData) {
|
||||
const oldOn = oldVnode.data.on || {}
|
||||
target = vnode.elm
|
||||
normalizeEvents(on)
|
||||
updateListeners(on, oldOn, add, remove, vnode.context)
|
||||
updateListeners(on, oldOn, add, remove, createOnceHandler, vnode.context)
|
||||
target = undefined
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
/* @flow */
|
||||
|
||||
import { getStyle, normalizeStyleBinding } from 'web/util/style'
|
||||
import { cached, camelize, extend, isDef, isUndef } from 'shared/util'
|
||||
import { cached, camelize, extend, isDef, isUndef, hyphenate } from 'shared/util'
|
||||
|
||||
const cssVarRE = /^--/
|
||||
const importantRE = /\s*!important$/
|
||||
@@ -10,7 +10,7 @@ const setProp = (el, name, val) => {
|
||||
if (cssVarRE.test(name)) {
|
||||
el.style.setProperty(name, val)
|
||||
} else if (importantRE.test(val)) {
|
||||
el.style.setProperty(name, val.replace(importantRE, ''), 'important')
|
||||
el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important')
|
||||
} else {
|
||||
const normalizedName = normalize(name)
|
||||
if (Array.isArray(val)) {
|
||||
|
||||
+1
-1
@@ -251,7 +251,7 @@ export function leave (vnode: VNodeWithData, rm: Function) {
|
||||
return
|
||||
}
|
||||
// record leaving element
|
||||
if (!vnode.data.show) {
|
||||
if (!vnode.data.show && el.parentNode) {
|
||||
(el.parentNode._pending || (el.parentNode._pending = {}))[(vnode.key: any)] = vnode
|
||||
}
|
||||
beforeLeave && beforeLeave(el)
|
||||
|
||||
+10
-5
@@ -122,11 +122,12 @@ export function getTransitionInfo (el: Element, expectedType?: ?string): {
|
||||
hasTransform: boolean;
|
||||
} {
|
||||
const styles: any = window.getComputedStyle(el)
|
||||
const transitionDelays: Array<string> = styles[transitionProp + 'Delay'].split(', ')
|
||||
const transitionDurations: Array<string> = styles[transitionProp + 'Duration'].split(', ')
|
||||
// JSDOM may return undefined for transition properties
|
||||
const transitionDelays: Array<string> = (styles[transitionProp + 'Delay'] || '').split(', ')
|
||||
const transitionDurations: Array<string> = (styles[transitionProp + 'Duration'] || '').split(', ')
|
||||
const transitionTimeout: number = getTimeout(transitionDelays, transitionDurations)
|
||||
const animationDelays: Array<string> = styles[animationProp + 'Delay'].split(', ')
|
||||
const animationDurations: Array<string> = styles[animationProp + 'Duration'].split(', ')
|
||||
const animationDelays: Array<string> = (styles[animationProp + 'Delay'] || '').split(', ')
|
||||
const animationDurations: Array<string> = (styles[animationProp + 'Duration'] || '').split(', ')
|
||||
const animationTimeout: number = getTimeout(animationDelays, animationDurations)
|
||||
|
||||
let type: ?string
|
||||
@@ -180,6 +181,10 @@ function getTimeout (delays: Array<string>, durations: Array<string>): number {
|
||||
}))
|
||||
}
|
||||
|
||||
// Old versions of Chromium (below 61.0.3163.100) formats floating pointer numbers
|
||||
// in a locale-dependent way, using a comma instead of a dot.
|
||||
// If comma is not replaced with a dot, the input will be rounded down (i.e. acting
|
||||
// as a floor function) causing unexpected behaviors
|
||||
function toMs (s: string): number {
|
||||
return Number(s.slice(0, -1)) * 1000
|
||||
return Number(s.slice(0, -1).replace(',', '.')) * 1000
|
||||
}
|
||||
|
||||
+3
-2
@@ -11,7 +11,8 @@ import {
|
||||
import {
|
||||
isBooleanAttr,
|
||||
isEnumeratedAttr,
|
||||
isFalsyAttrValue
|
||||
isFalsyAttrValue,
|
||||
convertEnumeratedValue
|
||||
} from 'web/util/attrs'
|
||||
|
||||
import { isSSRUnsafeAttr } from 'web/server/util'
|
||||
@@ -54,7 +55,7 @@ export function renderAttr (key: string, value: string): string {
|
||||
return ` ${key}="${key}"`
|
||||
}
|
||||
} else if (isEnumeratedAttr(key)) {
|
||||
return ` ${key}="${isFalsyAttrValue(value) || value === 'false' ? 'false' : 'true'}"`
|
||||
return ` ${key}="${escape(convertEnumeratedValue(key, value))}"`
|
||||
} else if (!isFalsyAttrValue(value)) {
|
||||
return ` ${key}="${escape(String(value))}"`
|
||||
}
|
||||
|
||||
+16
-3
@@ -1,6 +1,6 @@
|
||||
/* @flow */
|
||||
|
||||
import { escape } from '../util'
|
||||
import { escape, noUnitNumericStyleProps } from '../util'
|
||||
import { hyphenate } from 'shared/util'
|
||||
import { getStyle } from 'web/util/style'
|
||||
|
||||
@@ -11,15 +11,28 @@ export function genStyle (style: Object): string {
|
||||
const hyphenatedKey = hyphenate(key)
|
||||
if (Array.isArray(value)) {
|
||||
for (let i = 0, len = value.length; i < len; i++) {
|
||||
styleText += `${hyphenatedKey}:${value[i]};`
|
||||
styleText += normalizeValue(hyphenatedKey, value[i])
|
||||
}
|
||||
} else {
|
||||
styleText += `${hyphenatedKey}:${value};`
|
||||
styleText += normalizeValue(hyphenatedKey, value)
|
||||
}
|
||||
}
|
||||
return styleText
|
||||
}
|
||||
|
||||
function normalizeValue(key: string, value: any): string {
|
||||
if (
|
||||
typeof value === 'string' ||
|
||||
(typeof value === 'number' && noUnitNumericStyleProps[key]) ||
|
||||
value === 0
|
||||
) {
|
||||
return `${key}:${value};`
|
||||
} else {
|
||||
// invalid values
|
||||
return ``
|
||||
}
|
||||
}
|
||||
|
||||
export default function renderStyle (vnode: VNodeWithData): ?string {
|
||||
const styleText = genStyle(getStyle(vnode, false))
|
||||
if (styleText !== '') {
|
||||
|
||||
+46
-1
@@ -18,7 +18,7 @@ const isAttr = makeMap(
|
||||
'target,title,type,usemap,value,width,wrap'
|
||||
)
|
||||
|
||||
const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/
|
||||
const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/ // eslint-disable-line no-control-regex
|
||||
export const isSSRUnsafeAttr = (name: string): boolean => {
|
||||
return unsafeAttrCharRE.test(name)
|
||||
}
|
||||
@@ -54,3 +54,48 @@ export function escape (s: string) {
|
||||
function escapeChar (a) {
|
||||
return ESC[a] || a
|
||||
}
|
||||
|
||||
export const noUnitNumericStyleProps = {
|
||||
"animation-iteration-count": true,
|
||||
"border-image-outset": true,
|
||||
"border-image-slice": true,
|
||||
"border-image-width": true,
|
||||
"box-flex": true,
|
||||
"box-flex-group": true,
|
||||
"box-ordinal-group": true,
|
||||
"column-count": true,
|
||||
"columns": true,
|
||||
"flex": true,
|
||||
"flex-grow": true,
|
||||
"flex-positive": true,
|
||||
"flex-shrink": true,
|
||||
"flex-negative": true,
|
||||
"flex-order": true,
|
||||
"grid-row": true,
|
||||
"grid-row-end": true,
|
||||
"grid-row-span": true,
|
||||
"grid-row-start": true,
|
||||
"grid-column": true,
|
||||
"grid-column-end": true,
|
||||
"grid-column-span": true,
|
||||
"grid-column-start": true,
|
||||
"font-weight": true,
|
||||
"line-clamp": true,
|
||||
"line-height": true,
|
||||
"opacity": true,
|
||||
"order": true,
|
||||
"orphans": true,
|
||||
"tab-size": true,
|
||||
"widows": true,
|
||||
"z-index": true,
|
||||
"zoom": true,
|
||||
// SVG
|
||||
"fill-opacity": true,
|
||||
"flood-opacity": true,
|
||||
"stop-opacity": true,
|
||||
"stroke-dasharray": true,
|
||||
"stroke-dashoffset": true,
|
||||
"stroke-miterlimit": true,
|
||||
"stroke-opacity": true,
|
||||
"stroke-width": true
|
||||
}
|
||||
|
||||
+11
@@ -19,6 +19,17 @@ export const mustUseProp = (tag: string, type: ?string, attr: string): boolean =
|
||||
|
||||
export const isEnumeratedAttr = makeMap('contenteditable,draggable,spellcheck')
|
||||
|
||||
const isValidContentEditableValue = makeMap('events,caret,typing,plaintext-only')
|
||||
|
||||
export const convertEnumeratedValue = (key: string, value: any) => {
|
||||
return isFalsyAttrValue(value) || value === 'false'
|
||||
? 'false'
|
||||
// allow arbitrary string value for contenteditable
|
||||
: key === 'contenteditable' && isValidContentEditableValue(value)
|
||||
? value
|
||||
: 'true'
|
||||
}
|
||||
|
||||
export const isBooleanAttr = makeMap(
|
||||
'allowfullscreen,async,autofocus,autoplay,checked,compact,controls,declare,' +
|
||||
'default,defaultchecked,defaultmuted,defaultselected,defer,disabled,' +
|
||||
|
||||
+1
-2
@@ -8,7 +8,7 @@ export const parseStyleText = cached(function (cssText) {
|
||||
const propertyDelimiter = /:(.+)/
|
||||
cssText.split(listDelimiter).forEach(function (item) {
|
||||
if (item) {
|
||||
var tmp = item.split(propertyDelimiter)
|
||||
const tmp = item.split(propertyDelimiter)
|
||||
tmp.length > 1 && (res[tmp[0].trim()] = tmp[1].trim())
|
||||
}
|
||||
})
|
||||
@@ -69,4 +69,3 @@ export function getStyle (vnode: VNodeWithData, checkChild: boolean): Object {
|
||||
}
|
||||
return res
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -5,8 +5,7 @@ import { genComponentModel, genAssignmentCode } from 'compiler/directives/model'
|
||||
|
||||
export default function model (
|
||||
el: ASTElement,
|
||||
dir: ASTDirective,
|
||||
_warn: Function
|
||||
dir: ASTDirective
|
||||
): ?boolean {
|
||||
if (el.tag === 'input' || el.tag === 'textarea') {
|
||||
genDefaultModel(el, dir.value, dir.modifiers)
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import { makeMap } from 'shared/util'
|
||||
// must be sent to the native together.
|
||||
const isUnitaryTag = makeMap('cell,header,cell-slot,recycle-list', true)
|
||||
|
||||
function preTransformNode (el: ASTElement, options: CompilerOptions) {
|
||||
function preTransformNode (el: ASTElement) {
|
||||
if (isUnitaryTag(el.tag) && !el.attrsList.some(item => item.name === 'append')) {
|
||||
el.attrsMap.append = 'tree'
|
||||
el.attrsList.push({ name: 'append', value: 'tree' })
|
||||
|
||||
+2
-1
@@ -20,7 +20,8 @@ function transformNode (el: ASTElement, options: CompilerOptions) {
|
||||
warn(
|
||||
`class="${staticClass}": ` +
|
||||
'Interpolation inside attributes has been deprecated. ' +
|
||||
'Use v-bind or the colon shorthand instead.'
|
||||
'Use v-bind or the colon shorthand instead.',
|
||||
el.rawAttrsMap['class']
|
||||
)
|
||||
}
|
||||
if (!dynamic && classResult) {
|
||||
|
||||
+6
-1
@@ -13,7 +13,7 @@ function normalizeKeyName (str: string): string {
|
||||
return normalize(str)
|
||||
}
|
||||
|
||||
function transformNode (el: ASTElement, options: CompilerOptions) {
|
||||
function transformNode (el: ASTElement) {
|
||||
if (Array.isArray(el.attrsList)) {
|
||||
el.attrsList.forEach(attr => {
|
||||
if (attr.name && attr.name.match(/\-/)) {
|
||||
@@ -22,6 +22,11 @@ function transformNode (el: ASTElement, options: CompilerOptions) {
|
||||
el.attrsMap[realName] = el.attrsMap[attr.name]
|
||||
delete el.attrsMap[attr.name]
|
||||
}
|
||||
if (el.rawAttrsMap && el.rawAttrsMap[attr.name]) {
|
||||
el.rawAttrsMap[realName] = el.rawAttrsMap[attr.name]
|
||||
// $flow-disable-line
|
||||
delete el.rawAttrsMap[attr.name]
|
||||
}
|
||||
attr.name = realName
|
||||
}
|
||||
})
|
||||
|
||||
Generated
Vendored
+1
-4
@@ -3,10 +3,7 @@
|
||||
import { addAttr } from 'compiler/helpers'
|
||||
|
||||
// mark component root nodes as
|
||||
export function postTransformComponentRoot (
|
||||
el: ASTElement,
|
||||
options: WeexCompilerOptions
|
||||
) {
|
||||
export function postTransformComponentRoot (el: ASTElement) {
|
||||
if (!el.parent) {
|
||||
// component root
|
||||
addAttr(el, '@isComponentRoot', 'true')
|
||||
|
||||
+5
-5
@@ -23,10 +23,10 @@ function preTransformNode (el: ASTElement, options: WeexCompilerOptions) {
|
||||
currentRecycleList = el
|
||||
}
|
||||
if (shouldCompile(el, options)) {
|
||||
preTransformVBind(el, options)
|
||||
preTransformVBind(el)
|
||||
preTransformVIf(el, options) // also v-else-if and v-else
|
||||
preTransformVFor(el, options)
|
||||
preTransformVOnce(el, options)
|
||||
preTransformVOnce(el)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,12 +41,12 @@ function postTransformNode (el: ASTElement, options: WeexCompilerOptions) {
|
||||
// mark child component in parent template
|
||||
postTransformComponent(el, options)
|
||||
// mark root in child component template
|
||||
postTransformComponentRoot(el, options)
|
||||
postTransformComponentRoot(el)
|
||||
// <text>: transform children text into value attr
|
||||
if (el.tag === 'text') {
|
||||
postTransformText(el, options)
|
||||
postTransformText(el)
|
||||
}
|
||||
postTransformVOn(el, options)
|
||||
postTransformVOn(el)
|
||||
}
|
||||
if (el === currentRecycleList) {
|
||||
currentRecycleList = null
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ function genText (node: ASTNode) {
|
||||
return JSON.stringify(value)
|
||||
}
|
||||
|
||||
export function postTransformText (el: ASTElement, options: WeexCompilerOptions) {
|
||||
export function postTransformText (el: ASTElement) {
|
||||
// weex <text> can only contain text, so the parser
|
||||
// always generates a single child.
|
||||
if (el.children.length) {
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ function parseAttrName (name: string): string {
|
||||
return camelize(name.replace(bindRE, ''))
|
||||
}
|
||||
|
||||
export function preTransformVBind (el: ASTElement, options: WeexCompilerOptions) {
|
||||
export function preTransformVBind (el: ASTElement) {
|
||||
for (const attr in el.attrsMap) {
|
||||
if (bindRE.test(attr)) {
|
||||
const name: string = parseAttrName(attr)
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ function parseHandlerParams (handler: ASTElementHandler) {
|
||||
}
|
||||
}
|
||||
|
||||
export function postTransformVOn (el: ASTElement, options: WeexCompilerOptions) {
|
||||
export function postTransformVOn (el: ASTElement) {
|
||||
const events: ASTElementHandlers | void = el.events
|
||||
if (!events) {
|
||||
return
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ function containVOnce (el: ASTElement): boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
export function preTransformVOnce (el: ASTElement, options: WeexCompilerOptions) {
|
||||
export function preTransformVOnce (el: ASTElement) {
|
||||
if (containVOnce(el)) {
|
||||
getAndRemoveAttr(el, 'v-once', true)
|
||||
addRawAttr(el, '[[once]]', true)
|
||||
|
||||
+2
-1
@@ -23,7 +23,8 @@ function transformNode (el: ASTElement, options: CompilerOptions) {
|
||||
warn(
|
||||
`style="${String(staticStyle)}": ` +
|
||||
'Interpolation inside attributes has been deprecated. ' +
|
||||
'Use v-bind or the colon shorthand instead.'
|
||||
'Use v-bind or the colon shorthand instead.',
|
||||
el.rawAttrsMap['style']
|
||||
)
|
||||
}
|
||||
if (!dynamic && styleResult) {
|
||||
|
||||
+1
@@ -1 +1,2 @@
|
||||
export { compile } from 'weex/compiler/index'
|
||||
export { generateCodeFrame } from 'compiler/codeframe'
|
||||
|
||||
+21
-20
@@ -1,6 +1,6 @@
|
||||
/* @flow */
|
||||
|
||||
import { extend } from 'shared/util'
|
||||
import { extend, isObject } from 'shared/util'
|
||||
|
||||
function updateClass (oldVnode: VNodeWithData, vnode: VNodeWithData) {
|
||||
const el = vnode.elm
|
||||
@@ -15,25 +15,8 @@ function updateClass (oldVnode: VNodeWithData, vnode: VNodeWithData) {
|
||||
return
|
||||
}
|
||||
|
||||
const oldClassList = []
|
||||
// unlike web, weex vnode staticClass is an Array
|
||||
const oldStaticClass: any = oldData.staticClass
|
||||
if (oldStaticClass) {
|
||||
oldClassList.push.apply(oldClassList, oldStaticClass)
|
||||
}
|
||||
if (oldData.class) {
|
||||
oldClassList.push.apply(oldClassList, oldData.class)
|
||||
}
|
||||
|
||||
const classList = []
|
||||
// unlike web, weex vnode staticClass is an Array
|
||||
const staticClass: any = data.staticClass
|
||||
if (staticClass) {
|
||||
classList.push.apply(classList, staticClass)
|
||||
}
|
||||
if (data.class) {
|
||||
classList.push.apply(classList, data.class)
|
||||
}
|
||||
const oldClassList = makeClassList(oldData)
|
||||
const classList = makeClassList(data)
|
||||
|
||||
if (typeof el.setClassList === 'function') {
|
||||
el.setClassList(classList)
|
||||
@@ -49,6 +32,24 @@ function updateClass (oldVnode: VNodeWithData, vnode: VNodeWithData) {
|
||||
}
|
||||
}
|
||||
|
||||
function makeClassList (data: VNodeData): Array<string> {
|
||||
const classList = []
|
||||
// unlike web, weex vnode staticClass is an Array
|
||||
const staticClass: any = data.staticClass
|
||||
const dataClass = data.class
|
||||
if (staticClass) {
|
||||
classList.push.apply(classList, staticClass)
|
||||
}
|
||||
if (Array.isArray(dataClass)) {
|
||||
classList.push.apply(classList, dataClass)
|
||||
} else if (isObject(dataClass)) {
|
||||
classList.push.apply(classList, Object.keys(dataClass).filter(className => dataClass[className]))
|
||||
} else if (typeof dataClass === 'string') {
|
||||
classList.push.apply(classList, dataClass.trim().split(/\s+/))
|
||||
}
|
||||
return classList
|
||||
}
|
||||
|
||||
function getStyle (oldClassList: Array<string>, classList: Array<string>, ctx: Component): Object {
|
||||
// style is a weex-only injected object
|
||||
// compiled from <style> tags in weex files
|
||||
|
||||
+11
-14
@@ -4,10 +4,19 @@ import { updateListeners } from 'core/vdom/helpers/update-listeners'
|
||||
|
||||
let target: any
|
||||
|
||||
function createOnceHandler (event, handler, capture) {
|
||||
const _target = target // save current target element in closure
|
||||
return function onceHandler () {
|
||||
const res = handler.apply(null, arguments)
|
||||
if (res !== null) {
|
||||
remove(event, onceHandler, capture, _target)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function add (
|
||||
event: string,
|
||||
handler: Function,
|
||||
once: boolean,
|
||||
capture: boolean,
|
||||
passive?: boolean,
|
||||
params?: Array<any>
|
||||
@@ -16,18 +25,6 @@ function add (
|
||||
console.log('Weex do not support event in bubble phase.')
|
||||
return
|
||||
}
|
||||
if (once) {
|
||||
const oldHandler = handler
|
||||
const _target = target // save current target element in closure
|
||||
handler = function (ev) {
|
||||
const res = arguments.length === 1
|
||||
? oldHandler(ev)
|
||||
: oldHandler.apply(null, arguments)
|
||||
if (res !== null) {
|
||||
remove(event, null, null, _target)
|
||||
}
|
||||
}
|
||||
}
|
||||
target.addEvent(event, handler, params)
|
||||
}
|
||||
|
||||
@@ -47,7 +44,7 @@ function updateDOMListeners (oldVnode: VNodeWithData, vnode: VNodeWithData) {
|
||||
const on = vnode.data.on || {}
|
||||
const oldOn = oldVnode.data.on || {}
|
||||
target = vnode.elm
|
||||
updateListeners(on, oldOn, add, remove, vnode.context)
|
||||
updateListeners(on, oldOn, add, remove, createOnceHandler, vnode.context)
|
||||
target = undefined
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -70,7 +70,7 @@ function updateStyle (oldVnode: VNodeWithData, vnode: VNodeWithData) {
|
||||
|
||||
function toObject (arr) {
|
||||
const res = {}
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
if (arr[i]) {
|
||||
extend(res, arr[i])
|
||||
}
|
||||
|
||||
+2
-2
@@ -75,7 +75,7 @@ function enter (_, vnode) {
|
||||
const stylesheet = vnode.context.$options.style || {}
|
||||
const startState = stylesheet[startClass]
|
||||
const transitionProperties = (stylesheet['@TRANSITION'] && stylesheet['@TRANSITION'][activeClass]) || {}
|
||||
const endState = getEnterTargetState(el, stylesheet, startClass, toClass, activeClass, vnode.context)
|
||||
const endState = getEnterTargetState(el, stylesheet, startClass, toClass, activeClass)
|
||||
const needAnimation = Object.keys(endState).length > 0
|
||||
|
||||
const cb = el._enterCb = once(() => {
|
||||
@@ -229,7 +229,7 @@ function leave (vnode, rm) {
|
||||
}
|
||||
|
||||
// determine the target animation style for an entering transition.
|
||||
function getEnterTargetState (el, stylesheet, startClass, endClass, activeClass, vm) {
|
||||
function getEnterTargetState (el, stylesheet, startClass, endClass, activeClass) {
|
||||
const targetState = {}
|
||||
const startState = stylesheet[startClass]
|
||||
const endState = stylesheet[endClass]
|
||||
|
||||
+5
-5
@@ -4,7 +4,7 @@
|
||||
// makeMap() due to potential side effects, so these variables end up
|
||||
// bloating the web builds.
|
||||
|
||||
import { makeMap } from 'shared/util'
|
||||
import { makeMap, noop } from 'shared/util'
|
||||
|
||||
export const isReservedTag = makeMap(
|
||||
'template,script,style,element,content,slot,link,meta,svg,view,' +
|
||||
@@ -33,20 +33,20 @@ export const isUnaryTag = makeMap(
|
||||
true
|
||||
)
|
||||
|
||||
export function mustUseProp (tag: string, type: ?string, name: string): boolean {
|
||||
export function mustUseProp (): boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
export function getTagNamespace (tag?: string): string | void { }
|
||||
export function getTagNamespace (): void { }
|
||||
|
||||
export function isUnknownElement (tag?: string): boolean {
|
||||
export function isUnknownElement (): boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
export function query (el: string | Element, document: Object) {
|
||||
// document is injected by weex factory wrapper
|
||||
const placeholder = document.createComment('root')
|
||||
placeholder.hasAttribute = placeholder.removeAttribute = function () {} // hack for patch
|
||||
placeholder.hasAttribute = placeholder.removeAttribute = noop // hack for patch
|
||||
document.documentElement.appendChild(placeholder)
|
||||
return placeholder
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user