nav tabs on admin dashboard
This commit is contained in:
+15
-7
@@ -2,6 +2,7 @@
|
||||
|
||||
import type Watcher from './watcher'
|
||||
import { remove } from '../util/index'
|
||||
import config from '../config'
|
||||
|
||||
let uid = 0
|
||||
|
||||
@@ -36,23 +37,30 @@ export default class Dep {
|
||||
notify () {
|
||||
// stabilize the subscriber list first
|
||||
const subs = this.subs.slice()
|
||||
if (process.env.NODE_ENV !== 'production' && !config.async) {
|
||||
// subs aren't sorted in scheduler if not running async
|
||||
// we need to sort them now to make sure they fire in correct
|
||||
// order
|
||||
subs.sort((a, b) => a.id - b.id)
|
||||
}
|
||||
for (let i = 0, l = subs.length; i < l; i++) {
|
||||
subs[i].update()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// the current target watcher being evaluated.
|
||||
// this is globally unique because there could be only one
|
||||
// watcher being evaluated at any time.
|
||||
// The current target watcher being evaluated.
|
||||
// This is globally unique because only one watcher
|
||||
// can be evaluated at a time.
|
||||
Dep.target = null
|
||||
const targetStack = []
|
||||
|
||||
export function pushTarget (_target: ?Watcher) {
|
||||
if (Dep.target) targetStack.push(Dep.target)
|
||||
Dep.target = _target
|
||||
export function pushTarget (target: ?Watcher) {
|
||||
targetStack.push(target)
|
||||
Dep.target = target
|
||||
}
|
||||
|
||||
export function popTarget () {
|
||||
Dep.target = targetStack.pop()
|
||||
targetStack.pop()
|
||||
Dep.target = targetStack[targetStack.length - 1]
|
||||
}
|
||||
|
||||
+14
-11
@@ -37,7 +37,7 @@ export function toggleObserving (value: boolean) {
|
||||
export class Observer {
|
||||
value: any;
|
||||
dep: Dep;
|
||||
vmCount: number; // number of vms that has this object as root $data
|
||||
vmCount: number; // number of vms that have this object as root $data
|
||||
|
||||
constructor (value: any) {
|
||||
this.value = value
|
||||
@@ -45,10 +45,11 @@ export class Observer {
|
||||
this.vmCount = 0
|
||||
def(value, '__ob__', this)
|
||||
if (Array.isArray(value)) {
|
||||
const augment = hasProto
|
||||
? protoAugment
|
||||
: copyAugment
|
||||
augment(value, arrayMethods, arrayKeys)
|
||||
if (hasProto) {
|
||||
protoAugment(value, arrayMethods)
|
||||
} else {
|
||||
copyAugment(value, arrayMethods, arrayKeys)
|
||||
}
|
||||
this.observeArray(value)
|
||||
} else {
|
||||
this.walk(value)
|
||||
@@ -56,7 +57,7 @@ export class Observer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Walk through each property and convert them into
|
||||
* Walk through all properties and convert them into
|
||||
* getter/setters. This method should only be called when
|
||||
* value type is Object.
|
||||
*/
|
||||
@@ -80,17 +81,17 @@ export class Observer {
|
||||
// helpers
|
||||
|
||||
/**
|
||||
* Augment an target Object or Array by intercepting
|
||||
* Augment a target Object or Array by intercepting
|
||||
* the prototype chain using __proto__
|
||||
*/
|
||||
function protoAugment (target, src: Object, keys: any) {
|
||||
function protoAugment (target, src: Object) {
|
||||
/* eslint-disable no-proto */
|
||||
target.__proto__ = src
|
||||
/* eslint-enable no-proto */
|
||||
}
|
||||
|
||||
/**
|
||||
* Augment an target Object or Array by defining
|
||||
* Augment a target Object or Array by defining
|
||||
* hidden properties.
|
||||
*/
|
||||
/* istanbul ignore next */
|
||||
@@ -147,10 +148,10 @@ export function defineReactive (
|
||||
|
||||
// cater for pre-defined getter/setters
|
||||
const getter = property && property.get
|
||||
if (!getter && arguments.length === 2) {
|
||||
const setter = property && property.set
|
||||
if ((!getter || setter) && arguments.length === 2) {
|
||||
val = obj[key]
|
||||
}
|
||||
const setter = property && property.set
|
||||
|
||||
let childOb = !shallow && observe(val)
|
||||
Object.defineProperty(obj, key, {
|
||||
@@ -179,6 +180,8 @@ export function defineReactive (
|
||||
if (process.env.NODE_ENV !== 'production' && customSetter) {
|
||||
customSetter()
|
||||
}
|
||||
// #7981: for accessor properties without setter
|
||||
if (getter && !setter) return
|
||||
if (setter) {
|
||||
setter.call(obj, newVal)
|
||||
} else {
|
||||
|
||||
+33
-2
@@ -7,7 +7,8 @@ import { callHook, activateChildComponent } from '../instance/lifecycle'
|
||||
import {
|
||||
warn,
|
||||
nextTick,
|
||||
devtools
|
||||
devtools,
|
||||
inBrowser
|
||||
} from '../util/index'
|
||||
|
||||
export const MAX_UPDATE_COUNT = 100
|
||||
@@ -32,10 +33,32 @@ function resetSchedulerState () {
|
||||
waiting = flushing = false
|
||||
}
|
||||
|
||||
// Async edge case #6566 requires saving the timestamp when event listeners are
|
||||
// attached. However, calling performance.now() has a perf overhead especially
|
||||
// if the page has thousands of event listeners. Instead, we take a timestamp
|
||||
// every time the scheduler flushes and use that for all event listeners
|
||||
// attached during that flush.
|
||||
export let currentFlushTimestamp = 0
|
||||
|
||||
// Async edge case fix requires storing an event listener's attach timestamp.
|
||||
let getNow: () => number = Date.now
|
||||
|
||||
// Determine what event timestamp the browser is using. Annoyingly, the
|
||||
// timestamp can either be hi-res (relative to page load) or low-res
|
||||
// (relative to UNIX epoch), so in order to compare time we have to use the
|
||||
// same timestamp type when saving the flush timestamp.
|
||||
if (inBrowser && getNow() > document.createEvent('Event').timeStamp) {
|
||||
// if the low-res timestamp which is bigger than the event timestamp
|
||||
// (which is evaluated AFTER) it means the event is using a hi-res timestamp,
|
||||
// and we need to use the hi-res version for event listeners as well.
|
||||
getNow = () => performance.now()
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush both queues and run the watchers.
|
||||
*/
|
||||
function flushSchedulerQueue () {
|
||||
currentFlushTimestamp = getNow()
|
||||
flushing = true
|
||||
let watcher, id
|
||||
|
||||
@@ -53,6 +76,9 @@ function flushSchedulerQueue () {
|
||||
// as we run existing watchers
|
||||
for (index = 0; index < queue.length; index++) {
|
||||
watcher = queue[index]
|
||||
if (watcher.before) {
|
||||
watcher.before()
|
||||
}
|
||||
id = watcher.id
|
||||
has[id] = null
|
||||
watcher.run()
|
||||
@@ -95,7 +121,7 @@ function callUpdatedHooks (queue) {
|
||||
while (i--) {
|
||||
const watcher = queue[i]
|
||||
const vm = watcher.vm
|
||||
if (vm._watcher === watcher && vm._isMounted) {
|
||||
if (vm._watcher === watcher && vm._isMounted && !vm._isDestroyed) {
|
||||
callHook(vm, 'updated')
|
||||
}
|
||||
}
|
||||
@@ -142,6 +168,11 @@ export function queueWatcher (watcher: Watcher) {
|
||||
// queue the flush
|
||||
if (!waiting) {
|
||||
waiting = true
|
||||
|
||||
if (process.env.NODE_ENV !== 'production' && !config.async) {
|
||||
flushSchedulerQueue()
|
||||
return
|
||||
}
|
||||
nextTick(flushSchedulerQueue)
|
||||
}
|
||||
}
|
||||
|
||||
+5
-2
@@ -6,7 +6,8 @@ import {
|
||||
isObject,
|
||||
parsePath,
|
||||
_Set as Set,
|
||||
handleError
|
||||
handleError,
|
||||
noop
|
||||
} from '../util/index'
|
||||
|
||||
import { traverse } from './traverse'
|
||||
@@ -37,6 +38,7 @@ export default class Watcher {
|
||||
newDeps: Array<Dep>;
|
||||
depIds: SimpleSet;
|
||||
newDepIds: SimpleSet;
|
||||
before: ?Function;
|
||||
getter: Function;
|
||||
value: any;
|
||||
|
||||
@@ -58,6 +60,7 @@ export default class Watcher {
|
||||
this.user = !!options.user
|
||||
this.lazy = !!options.lazy
|
||||
this.sync = !!options.sync
|
||||
this.before = options.before
|
||||
} else {
|
||||
this.deep = this.user = this.lazy = this.sync = false
|
||||
}
|
||||
@@ -78,7 +81,7 @@ export default class Watcher {
|
||||
} else {
|
||||
this.getter = parsePath(expOrFn)
|
||||
if (!this.getter) {
|
||||
this.getter = function () {}
|
||||
this.getter = noop
|
||||
process.env.NODE_ENV !== 'production' && warn(
|
||||
`Failed watching path: "${expOrFn}" ` +
|
||||
'Watcher only accepts simple dot-delimited paths. ' +
|
||||
|
||||
Reference in New Issue
Block a user