一大波精简
parent
099378aedd
commit
ebbd93cd97
|
@ -1,5 +1,4 @@
|
||||||
import { Anot } from './seed/core'
|
import Anot from './seed/index'
|
||||||
import './seed/lang'
|
|
||||||
|
|
||||||
import './filters/index'
|
import './filters/index'
|
||||||
import './dom/modern'
|
import './dom/modern'
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import { Anot } from './seed/core'
|
import Anot from './seed/index'
|
||||||
import './seed/lang'
|
|
||||||
|
|
||||||
import './filters/index'
|
import './filters/index'
|
||||||
import './dom/modern'
|
import './dom/modern'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Anot } from '../seed/core'
|
import Anot from '../seed/index'
|
||||||
import { cssDiff } from './css'
|
import { cssDiff } from './css'
|
||||||
import { updateAttrs } from '../dom/attr/modern'
|
import { updateAttrs } from '../dom/attr/modern'
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,21 @@ import { updateModel } from './updateDataHandle'
|
||||||
|
|
||||||
var rchangeFilter = /\|\s*change\b/
|
var rchangeFilter = /\|\s*change\b/
|
||||||
var rdebounceFilter = /\|\s*debounce(?:\(([^)]+)\))?/
|
var rdebounceFilter = /\|\s*debounce(?:\(([^)]+)\))?/
|
||||||
|
var PARSER_FN = {
|
||||||
|
number(a) {
|
||||||
|
return a === '' ? '' : +a || 0
|
||||||
|
},
|
||||||
|
string(a) {
|
||||||
|
return a === null || a === void 0 ? '' : a + ''
|
||||||
|
},
|
||||||
|
boolean(a) {
|
||||||
|
if (a === '') {
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
return a === 'true' || a === '1'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function duplexBeforeInit() {
|
export function duplexBeforeInit() {
|
||||||
var expr = this.expr
|
var expr = this.expr
|
||||||
if (rchangeFilter.test(expr)) {
|
if (rchangeFilter.test(expr)) {
|
||||||
|
@ -144,7 +159,7 @@ try {
|
||||||
|
|
||||||
function parseValue(val) {
|
function parseValue(val) {
|
||||||
for (var i = 0, k; (k = this.parsers[i++]); ) {
|
for (var i = 0, k; (k = this.parsers[i++]); ) {
|
||||||
var fn = Anot.parsers[k]
|
var fn = PARSER_FN[k]
|
||||||
if (fn) {
|
if (fn) {
|
||||||
val = fn.call(this, val)
|
val = fn.call(this, val)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Anot } from '../seed/core'
|
import Anot from '../seed/index'
|
||||||
|
|
||||||
Anot.directive('expr', {
|
Anot.directive('expr', {
|
||||||
update: function(vdom, value) {
|
update: function(vdom, value) {
|
||||||
|
|
|
@ -1,4 +1,11 @@
|
||||||
import { Anot, createFragment, platform, isObject, ap } from '../seed/core'
|
import {
|
||||||
|
Anot,
|
||||||
|
createFragment,
|
||||||
|
platform,
|
||||||
|
isObject,
|
||||||
|
ap,
|
||||||
|
makeHashCode
|
||||||
|
} from '../seed/core'
|
||||||
|
|
||||||
import { VFragment } from '../vdom/VFragment'
|
import { VFragment } from '../vdom/VFragment'
|
||||||
import { $$skipArray } from '../vmodel/reserved'
|
import { $$skipArray } from '../vmodel/reserved'
|
||||||
|
@ -39,7 +46,7 @@ Anot.directive('for', {
|
||||||
this.expr = arr[1]
|
this.expr = arr[1]
|
||||||
this.keyName = kv[0]
|
this.keyName = kv[0]
|
||||||
this.valName = kv[1]
|
this.valName = kv[1]
|
||||||
this.signature = Anot.makeHashCode('for')
|
this.signature = makeHashCode('for')
|
||||||
if (asName) {
|
if (asName) {
|
||||||
this.asName = asName
|
this.asName = asName
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,11 +44,11 @@ Anot.directive('visible', {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// fix firefox BUG,必须挂到页面上
|
||||||
if (
|
if (
|
||||||
dom.style.display === '' &&
|
dom.style.display === '' &&
|
||||||
Anot(dom).css('display') === none &&
|
Anot(dom).css('display') === none &&
|
||||||
// fix firefox BUG,必须挂到页面上
|
dom.ownerDocument.contains(dom)
|
||||||
Anot.contains(dom.ownerDocument, dom)
|
|
||||||
) {
|
) {
|
||||||
value = parseDisplay(dom)
|
value = parseDisplay(dom)
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ export { cssMap, cssHooks }
|
||||||
Anot.cssNumber = oneObject(
|
Anot.cssNumber = oneObject(
|
||||||
'animationIterationCount,columnCount,order,flex,flexGrow,flexShrink,fillOpacity,fontWeight,lineHeight,opacity,orphans,widows,zIndex,zoom'
|
'animationIterationCount,columnCount,order,flex,flexGrow,flexShrink,fillOpacity,fontWeight,lineHeight,opacity,orphans,widows,zIndex,zoom'
|
||||||
)
|
)
|
||||||
var prefixes = ['', '-webkit-', '-o-', '-moz-', '-ms-']
|
var prefixes = ['', '-webkit-', '-moz-']
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
Anot.cssName = function(name, host, camelCase) {
|
Anot.cssName = function(name, host, camelCase) {
|
||||||
if (cssMap[name]) {
|
if (cssMap[name]) {
|
||||||
|
@ -171,12 +171,7 @@ function showHidden(node, array) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* istanbul ignore next*/
|
/* istanbul ignore next*/
|
||||||
Anot.each(
|
Anot.each({ Width: 'width', Height: 'height' }, function(name, method) {
|
||||||
{
|
|
||||||
Width: 'width',
|
|
||||||
Height: 'height'
|
|
||||||
},
|
|
||||||
function(name, method) {
|
|
||||||
var clientProp = 'client' + name,
|
var clientProp = 'client' + name,
|
||||||
scrollProp = 'scroll' + name,
|
scrollProp = 'scroll' + name,
|
||||||
offsetProp = 'offset' + name
|
offsetProp = 'offset' + name
|
||||||
|
@ -266,8 +261,7 @@ Anot.each(
|
||||||
includeMargin === true ? 2 : 0
|
includeMargin === true ? 2 : 0
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
)
|
|
||||||
|
|
||||||
export function getWindow(node) {
|
export function getWindow(node) {
|
||||||
return node.window || node.defaultView || node.parentWindow || false
|
return node.window || node.defaultView || node.parentWindow || false
|
||||||
|
|
|
@ -20,7 +20,7 @@ Anot.parseHTML = function(html) {
|
||||||
html = html.replace(rxhtml, '<$1></$2>').trim()
|
html = html.replace(rxhtml, '<$1></$2>').trim()
|
||||||
var hasCache = htmlCache.get(html)
|
var hasCache = htmlCache.get(html)
|
||||||
if (hasCache) {
|
if (hasCache) {
|
||||||
return Anot.cloneNode(hasCache)
|
return hasCache.cloneNode(true)
|
||||||
}
|
}
|
||||||
var vnodes = fromString(html)
|
var vnodes = fromString(html)
|
||||||
for (var i = 0, el; (el = vnodes[i++]); ) {
|
for (var i = 0, el; (el = vnodes[i++]); ) {
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
* shim,class,data,css,val,html,event,ready *
|
* shim,class,data,css,val,html,event,ready *
|
||||||
********************************************************************/
|
********************************************************************/
|
||||||
|
|
||||||
import './shim/modern'
|
|
||||||
import './class/modern'
|
|
||||||
import './attr/modern'
|
import './attr/modern'
|
||||||
import './css/modern'
|
import './css/modern'
|
||||||
import './val/modern'
|
import './val/modern'
|
||||||
|
|
|
@ -16,10 +16,6 @@ Anot.ready = function(fn) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Anot.ready(function() {
|
|
||||||
Anot.scan && Anot.scan(document.body)
|
|
||||||
})
|
|
||||||
|
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
function bootstrap() {
|
function bootstrap() {
|
||||||
if (document.readyState === 'complete') {
|
if (document.readyState === 'complete') {
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
/* istanbul ignore next */
|
|
||||||
export function fixContains(root, el) {
|
|
||||||
try {
|
|
||||||
//IE6-8,游离于DOM树外的文本节点,访问parentNode有时会抛错
|
|
||||||
while ((el = el.parentNode)) {
|
|
||||||
if (el === root) return true
|
|
||||||
}
|
|
||||||
} catch (e) {}
|
|
||||||
return false
|
|
||||||
}
|
|
|
@ -1,41 +0,0 @@
|
||||||
//safari5+是把contains方法放在Element.prototype上而不是Node.prototype
|
|
||||||
import { Anot, root } from '../../seed/core'
|
|
||||||
import { fixContains } from './fixContains'
|
|
||||||
export { Anot }
|
|
||||||
|
|
||||||
Anot.contains = fixContains
|
|
||||||
|
|
||||||
Anot.cloneNode = function(a) {
|
|
||||||
return a.cloneNode(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!document.contains) {
|
|
||||||
Node.prototype.contains = function(child) {
|
|
||||||
//IE6-8没有Node对象
|
|
||||||
return fixContains(this, child)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function fixFF(prop, cb) {
|
|
||||||
//firefox12 http://caniuse.com/#search=outerHTML
|
|
||||||
if (!(prop in root)) {
|
|
||||||
HTMLElement.prototype.__defineGetter__(prop, cb)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fixFF('outerHTML', function() {
|
|
||||||
//https://developer.mozilla.org/en-US/docs/Web/API/ParentNode/children
|
|
||||||
var div = document.createElement('div')
|
|
||||||
div.appendChild(this)
|
|
||||||
return div.innerHTML
|
|
||||||
})
|
|
||||||
fixFF('children', function() {
|
|
||||||
var children = []
|
|
||||||
for (var i = 0, el; (el = this.childNodes[i++]); ) {
|
|
||||||
if (el.nodeType === 1) {
|
|
||||||
children.push(el)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return children
|
|
||||||
})
|
|
||||||
fixFF('innerText', function() {
|
|
||||||
return this.textContent
|
|
||||||
})
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Anot, escapeRegExp } from '../seed/core'
|
import { Anot, escapeRegExp, isObject } from '../seed/core'
|
||||||
import { $$skipArray } from '../vmodel/reserved'
|
import { $$skipArray } from '../vmodel/reserved'
|
||||||
|
|
||||||
export function orderBy(array, by, decend) {
|
export function orderBy(array, by, decend) {
|
||||||
|
@ -96,7 +96,7 @@ export function filterBy(array, search, ...args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function selectBy(data, array, defaults) {
|
export function selectBy(data, array, defaults) {
|
||||||
if (Anot.isObject(data) && !Array.isArray(data)) {
|
if (isObject(data) && !Array.isArray(data)) {
|
||||||
var target = []
|
var target = []
|
||||||
return recovery(target, array, function(name) {
|
return recovery(target, array, function(name) {
|
||||||
target.push(
|
target.push(
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Anot, directives } from '../seed/core'
|
import { Anot, directives, oneObject } from '../seed/core'
|
||||||
export var eventMap = Anot.oneObject(
|
export var eventMap = oneObject(
|
||||||
'animationend,blur,change,input,' +
|
'animationend,blur,change,input,' +
|
||||||
'click,dblclick,focus,keydown,keypress,keyup,mousedown,mouseenter,' +
|
'click,dblclick,focus,keydown,keypress,keyup,mousedown,mouseenter,' +
|
||||||
'mouseleave,mousemove,mouseout,mouseover,mouseup,scan,scroll,submit',
|
'mouseleave,mousemove,mouseout,mouseover,mouseup,scan,scroll,submit',
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { Anot, Cache } from '../seed/core'
|
import { Anot, Cache, oneObject } from '../seed/core'
|
||||||
import { clearString, stringPool, fill, rfill, dig } from '../vtree/clearString'
|
import { clearString, stringPool, fill, rfill, dig } from '../vtree/clearString'
|
||||||
|
|
||||||
var keyMap = Anot.oneObject(
|
var keyMap = oneObject(
|
||||||
'break,case,catch,continue,debugger,default,delete,do,else,false,' +
|
'break,case,catch,continue,debugger,default,delete,do,else,false,' +
|
||||||
'finally,for,function,if,in,instanceof,new,null,return,switch,this,' +
|
'finally,for,function,if,in,instanceof,new,null,return,switch,this,' +
|
||||||
'throw,true,try,typeof,var,void,while,with,' /* 关键字*/ +
|
'throw,true,try,typeof,var,void,while,with,' /* 关键字*/ +
|
||||||
|
|
|
@ -7,12 +7,6 @@ export function Anot(el) {
|
||||||
return new Anot.init(el)
|
return new Anot.init(el)
|
||||||
}
|
}
|
||||||
|
|
||||||
Anot.init = function(el) {
|
|
||||||
this[0] = this.element = el
|
|
||||||
}
|
|
||||||
|
|
||||||
Anot.fn = Anot.prototype = Anot.init.prototype
|
|
||||||
|
|
||||||
export var rword = /[^, ]+/g
|
export var rword = /[^, ]+/g
|
||||||
export var rnowhite = /\S+/g //存在非空字符
|
export var rnowhite = /\S+/g //存在非空字符
|
||||||
export var platform = {} //用于放置平台差异的方法与属性
|
export var platform = {} //用于放置平台差异的方法与属性
|
||||||
|
@ -114,7 +108,6 @@ export var validators = {}
|
||||||
export var cssHooks = {}
|
export var cssHooks = {}
|
||||||
|
|
||||||
window.Anot = Anot
|
window.Anot = Anot
|
||||||
Anot.platform = platform
|
|
||||||
|
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
export function createFragment() {
|
export function createFragment() {
|
||||||
|
@ -170,24 +163,6 @@ Object.assign(Anot, {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
evaluatorPool: new Cache(888),
|
evaluatorPool: new Cache(888),
|
||||||
parsers: {
|
|
||||||
number: function(a) {
|
|
||||||
return a === '' ? '' : +a || 0
|
|
||||||
},
|
|
||||||
string: function(a) {
|
|
||||||
return a === null || a === void 0 ? '' : a + ''
|
|
||||||
},
|
|
||||||
boolean: function(a) {
|
|
||||||
if (a === '') {
|
|
||||||
return a
|
|
||||||
}
|
|
||||||
return a === 'true' || a === '1'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
oneObject,
|
|
||||||
inspect,
|
|
||||||
ohasOwn,
|
|
||||||
vmodels: {},
|
vmodels: {},
|
||||||
|
|
||||||
directives,
|
directives,
|
||||||
|
@ -195,15 +170,11 @@ Object.assign(Anot, {
|
||||||
|
|
||||||
eventHooks,
|
eventHooks,
|
||||||
eventListeners,
|
eventListeners,
|
||||||
validators,
|
|
||||||
cssHooks,
|
cssHooks,
|
||||||
|
|
||||||
noop,
|
noop,
|
||||||
|
|
||||||
isObject,
|
|
||||||
range,
|
range,
|
||||||
hyphen,
|
hyphen,
|
||||||
camelize,
|
camelize
|
||||||
|
|
||||||
makeHashCode
|
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
//这里放置存在异议的方法
|
//这里放置存在异议的方法
|
||||||
import { Anot, ohasOwn, inspect } from './core'
|
import { Anot, inspect, platform, isObject } from './core'
|
||||||
export { Anot }
|
export default Anot
|
||||||
|
|
||||||
var rwindow = /^\[object (?:Window|DOMWindow|global)\]$/
|
var rwindow = /^\[object (?:Window|DOMWindow|global)\]$/
|
||||||
var rarraylike = /(Array|List|Collection|Map|Arguments|Set)\]$/
|
var rarraylike = /(Array|List|Collection|Map|Arguments|Set)\]$/
|
||||||
|
|
||||||
|
@ -39,6 +40,67 @@ Anot.isPlainObject = function(obj) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Anot.nextTick = (function() {
|
||||||
|
let queue = []
|
||||||
|
function callback() {
|
||||||
|
let n = queue.length
|
||||||
|
for (let i = 0; i < n; i++) {
|
||||||
|
queue[i]()
|
||||||
|
}
|
||||||
|
queue = queue.slice(n)
|
||||||
|
}
|
||||||
|
|
||||||
|
let node = document.createTextNode('<!-- -->')
|
||||||
|
new MutationObserver(callback).observe(node, { characterData: true })
|
||||||
|
|
||||||
|
let bool = false
|
||||||
|
return function(fn) {
|
||||||
|
queue.push(fn)
|
||||||
|
bool = !bool
|
||||||
|
node.data = bool
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
|
||||||
|
Anot.init = function(source) {
|
||||||
|
if (source) {
|
||||||
|
if (Anot.isPlainObject(source)) {
|
||||||
|
var id = source.$id
|
||||||
|
var vm = Anot.vmodels[id]
|
||||||
|
|
||||||
|
if (!id) {
|
||||||
|
throw new Error(`vm的$id必须声明`)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vm) {
|
||||||
|
throw new Error(`vm实例[${id}]已经存在`)
|
||||||
|
}
|
||||||
|
vm = platform.modelFactory(source)
|
||||||
|
Anot.vmodels[id] = vm
|
||||||
|
|
||||||
|
Anot.nextTick(function() {
|
||||||
|
let $elem = document.querySelector('[anot=' + vm.$id + ']')
|
||||||
|
if ($elem) {
|
||||||
|
if ($elem === document.body) {
|
||||||
|
Anot.scan($elem)
|
||||||
|
} else {
|
||||||
|
let _parent = $elem
|
||||||
|
while ((_parent = _parent.parentNode)) {
|
||||||
|
if (_parent.__VM__) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Anot.scan($elem.parentNode, _parent && _parent.__VM__)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return vm
|
||||||
|
}
|
||||||
|
this[0] = this.element = source
|
||||||
|
}
|
||||||
|
|
||||||
|
Anot.fn = Anot.prototype = Anot.init.prototype
|
||||||
|
|
||||||
//与jQuery.extend方法,可用于浅拷贝,深拷贝
|
//与jQuery.extend方法,可用于浅拷贝,深拷贝
|
||||||
Anot.mix = Anot.fn.mix = function() {
|
Anot.mix = Anot.fn.mix = function() {
|
||||||
var options,
|
var options,
|
|
@ -1,4 +1,4 @@
|
||||||
import { Anot } from '../seed/core'
|
import { Anot, oneObject } from '../seed/core'
|
||||||
|
|
||||||
export function VElement(type, props, children, isVoidTag) {
|
export function VElement(type, props, children, isVoidTag) {
|
||||||
this.nodeName = type
|
this.nodeName = type
|
||||||
|
@ -84,7 +84,7 @@ function createSVG(type) {
|
||||||
return document.createElementNS('http://www.w3.org/2000/svg', type)
|
return document.createElementNS('http://www.w3.org/2000/svg', type)
|
||||||
}
|
}
|
||||||
|
|
||||||
var svgTags = Anot.oneObject(
|
var svgTags = oneObject(
|
||||||
'circle,defs,ellipse,image,line,' +
|
'circle,defs,ellipse,image,line,' +
|
||||||
'path,polygon,polyline,rect,symbol,text,use,g,svg'
|
'path,polygon,polyline,rect,symbol,text,use,g,svg'
|
||||||
)
|
)
|
||||||
|
|
|
@ -4,7 +4,7 @@ import {
|
||||||
reportObserved,
|
reportObserved,
|
||||||
propagateChanged
|
propagateChanged
|
||||||
} from './transaction'
|
} from './transaction'
|
||||||
import { Anot, platform } from '../seed/core'
|
import { Anot, platform, isObject } from '../seed/core'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -59,7 +59,7 @@ export class Mutation {
|
||||||
set(newValue) {
|
set(newValue) {
|
||||||
var oldValue = this.value
|
var oldValue = this.value
|
||||||
if (newValue !== oldValue) {
|
if (newValue !== oldValue) {
|
||||||
if (Anot.isObject(newValue)) {
|
if (isObject(newValue)) {
|
||||||
var hash = oldValue && oldValue.$hashcode
|
var hash = oldValue && oldValue.$hashcode
|
||||||
var childVM = platform.createProxy(newValue, this)
|
var childVM = platform.createProxy(newValue, this)
|
||||||
if (childVM) {
|
if (childVM) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Anot, ap, platform, isObject } from '../seed/core'
|
import { Anot, ap, platform, isObject, makeHashCode } from '../seed/core'
|
||||||
import { Mutation } from './Mutation'
|
import { Mutation } from './Mutation'
|
||||||
|
|
||||||
var _splice = ap.splice
|
var _splice = ap.splice
|
||||||
|
@ -105,7 +105,7 @@ export function listFactory(array, stop, dd) {
|
||||||
|
|
||||||
Object.defineProperty(array, '$model', platform.modelAccessor)
|
Object.defineProperty(array, '$model', platform.modelAccessor)
|
||||||
|
|
||||||
platform.hideProperty(array, '$hashcode', Anot.makeHashCode('$'))
|
platform.hideProperty(array, '$hashcode', makeHashCode('$'))
|
||||||
platform.hideProperty(array, '$events', { __dep__: dd || new Mutation() })
|
platform.hideProperty(array, '$events', { __dep__: dd || new Mutation() })
|
||||||
}
|
}
|
||||||
var _dd = array.$events && array.$events.__dep__
|
var _dd = array.$events && array.$events.__dep__
|
||||||
|
|
|
@ -1,11 +1,10 @@
|
||||||
import { Anot, platform, isObject } from '../seed/core'
|
import { Anot, platform, isObject, makeHashCode } from '../seed/core'
|
||||||
import { $$skipArray } from './reserved'
|
import { $$skipArray } from './reserved'
|
||||||
import { Mutation } from './Mutation'
|
import { Mutation } from './Mutation'
|
||||||
import { Computed } from './Computed'
|
import { Computed } from './Computed'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 这里放置ViewModel模块的共用方法
|
* 这里放置ViewModel模块的共用方法
|
||||||
* Anot.define: 全框架最重要的方法,生成用户VM
|
|
||||||
* IProxy, 基本用户数据产生的一个数据对象,基于$model与vmodel之间的形态
|
* IProxy, 基本用户数据产生的一个数据对象,基于$model与vmodel之间的形态
|
||||||
* modelFactory: 生成用户VM
|
* modelFactory: 生成用户VM
|
||||||
* canHijack: 判定此属性是否该被劫持,加入数据监听与分发的的逻辑
|
* canHijack: 判定此属性是否该被劫持,加入数据监听与分发的的逻辑
|
||||||
|
@ -15,18 +14,6 @@ import { Computed } from './Computed'
|
||||||
* fuseFactory: 两个ms-controller间产生的代理VM的生成工厂
|
* fuseFactory: 两个ms-controller间产生的代理VM的生成工厂
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Anot.define = function(definition) {
|
|
||||||
var $id = definition.$id
|
|
||||||
if (!$id) {
|
|
||||||
console.error('vm.$id must be specified')
|
|
||||||
}
|
|
||||||
if (Anot.vmodels[$id]) {
|
|
||||||
console.warn('error:[' + $id + '] had defined!')
|
|
||||||
}
|
|
||||||
var vm = platform.modelFactory(definition)
|
|
||||||
return (Anot.vmodels[$id] = vm)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Anot改用Proxy来创建VM,因此
|
* Anot改用Proxy来创建VM,因此
|
||||||
*/
|
*/
|
||||||
|
@ -34,7 +21,7 @@ Anot.define = function(definition) {
|
||||||
export function IProxy(definition, dd) {
|
export function IProxy(definition, dd) {
|
||||||
Anot.mix(this, definition)
|
Anot.mix(this, definition)
|
||||||
Anot.mix(this, $$skipArray)
|
Anot.mix(this, $$skipArray)
|
||||||
this.$hashcode = Anot.makeHashCode('$')
|
this.$hashcode = makeHashCode('$')
|
||||||
this.$id = this.$id || this.$hashcode
|
this.$id = this.$id || this.$hashcode
|
||||||
this.$events = {
|
this.$events = {
|
||||||
__dep__: dd || new Mutation(this.$id)
|
__dep__: dd || new Mutation(this.$id)
|
||||||
|
|
Reference in New Issue