移除非浏览器环境的代码
parent
2fcdf274cc
commit
eb3d4f82fc
|
@ -16,15 +16,15 @@ export default [
|
||||||
name: '_Anot'
|
name: '_Anot'
|
||||||
},
|
},
|
||||||
plugins: [esm()]
|
plugins: [esm()]
|
||||||
},
|
|
||||||
{
|
|
||||||
input: 'src/anot.touch.js',
|
|
||||||
output: {
|
|
||||||
file: 'dist/anot.touch.js',
|
|
||||||
format: 'iife',
|
|
||||||
sourcemap: true,
|
|
||||||
name: '_Anot'
|
|
||||||
},
|
|
||||||
plugins: [esm()]
|
|
||||||
}
|
}
|
||||||
|
// {
|
||||||
|
// input: 'src/anot.touch.js',
|
||||||
|
// output: {
|
||||||
|
// file: 'dist/anot.touch.js',
|
||||||
|
// format: 'iife',
|
||||||
|
// sourcemap: true,
|
||||||
|
// name: '_Anot'
|
||||||
|
// },
|
||||||
|
// plugins: [esm()]
|
||||||
|
// }
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Anot } from './seed/core'
|
import { Anot } from './seed/core'
|
||||||
import './seed/lang.modern'
|
import './seed/lang'
|
||||||
|
|
||||||
import './filters/index'
|
import './filters/index'
|
||||||
import './dom/modern'
|
import './dom/modern'
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Anot } from './seed/core'
|
import { Anot } from './seed/core'
|
||||||
import './seed/lang.modern'
|
import './seed/lang'
|
||||||
|
|
||||||
import './filters/index'
|
import './filters/index'
|
||||||
import './dom/modern'
|
import './dom/modern'
|
||||||
|
|
|
@ -5,13 +5,7 @@
|
||||||
* 2. value属性重写
|
* 2. value属性重写
|
||||||
* 3. 定时器轮询
|
* 3. 定时器轮询
|
||||||
*/
|
*/
|
||||||
import {
|
import { Anot, getShortID as markID } from '../../seed/core'
|
||||||
Anot,
|
|
||||||
getShortID as markID,
|
|
||||||
window,
|
|
||||||
document,
|
|
||||||
msie
|
|
||||||
} from '../../seed/core'
|
|
||||||
import { updateModel } from './updateDataHandle'
|
import { updateModel } from './updateDataHandle'
|
||||||
|
|
||||||
export function updateDataEvents(dom, data) {
|
export function updateDataEvents(dom, data) {
|
||||||
|
@ -48,9 +42,6 @@ export function updateDataEvents(dom, data) {
|
||||||
//https://github.com/RubyLouvre/Anot/issues/1368#issuecomment-220503284
|
//https://github.com/RubyLouvre/Anot/issues/1368#issuecomment-220503284
|
||||||
events.compositionstart = openComposition
|
events.compositionstart = openComposition
|
||||||
events.compositionend = closeComposition
|
events.compositionend = closeComposition
|
||||||
if (Anot.msie) {
|
|
||||||
events.keyup = updateModelKeyDown
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ var impDir = Anot.directive('important', {
|
||||||
throw 'error! no vmodel called ' + name
|
throw 'error! no vmodel called ' + name
|
||||||
},
|
},
|
||||||
update: function(node, attrName, $id) {
|
update: function(node, attrName, $id) {
|
||||||
if (!Anot.inBrowser) return
|
|
||||||
var dom = Anot.vdom(node, 'toDOM')
|
var dom = Anot.vdom(node, 'toDOM')
|
||||||
if (dom.nodeType === 1) {
|
if (dom.nodeType === 1) {
|
||||||
dom.removeAttribute(attrName)
|
dom.removeAttribute(attrName)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Anot, inBrowser } from '../seed/core'
|
import { Anot } from '../seed/core'
|
||||||
|
|
||||||
import { addScope, makeHandle } from '../parser/index'
|
import { addScope, makeHandle } from '../parser/index'
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Anot, inBrowser } from '../seed/core'
|
import { Anot } from '../seed/core'
|
||||||
|
|
||||||
Anot.directive('text', {
|
Anot.directive('text', {
|
||||||
delay: true,
|
delay: true,
|
||||||
|
@ -9,10 +9,10 @@ Anot.directive('text', {
|
||||||
}
|
}
|
||||||
var child = { nodeName: '#text', nodeValue: this.getValue() }
|
var child = { nodeName: '#text', nodeValue: this.getValue() }
|
||||||
node.children.splice(0, node.children.length, child)
|
node.children.splice(0, node.children.length, child)
|
||||||
if (inBrowser) {
|
|
||||||
Anot.clearHTML(node.dom)
|
Anot.clearHTML(node.dom)
|
||||||
node.dom.appendChild(Anot.vdom(child, 'toDOM'))
|
node.dom.appendChild(Anot.vdom(child, 'toDOM'))
|
||||||
}
|
|
||||||
this.node = child
|
this.node = child
|
||||||
var type = 'expr'
|
var type = 'expr'
|
||||||
this.type = this.name = type
|
this.type = this.name = type
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Anot, window, document } from '../../seed/core'
|
import { Anot } from '../../seed/core'
|
||||||
import { propMap } from './propMap'
|
import { propMap } from './propMap'
|
||||||
|
|
||||||
var rsvg = /^\[object SVG\w*Element\]$/
|
var rsvg = /^\[object SVG\w*Element\]$/
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Anot, oneObject, cssHooks, window } from '../../seed/core'
|
import { Anot, oneObject, cssHooks } from '../../seed/core'
|
||||||
|
|
||||||
var cssMap = oneObject('float', 'cssFloat')
|
var cssMap = oneObject('float', 'cssFloat')
|
||||||
export { cssMap, cssHooks }
|
export { cssMap, cssHooks }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Anot, document } from '../../seed/core'
|
import { Anot } from '../../seed/core'
|
||||||
|
|
||||||
import { avEvent } from './share'
|
import { avEvent } from './share'
|
||||||
export { avEvent }
|
export { avEvent }
|
||||||
|
|
|
@ -1,16 +1,7 @@
|
||||||
import {
|
import { Anot, _slice, eventHooks, root, getShortID } from '../../seed/core'
|
||||||
Anot,
|
|
||||||
_slice,
|
|
||||||
eventHooks,
|
|
||||||
modern,
|
|
||||||
window,
|
|
||||||
document,
|
|
||||||
root,
|
|
||||||
getShortID
|
|
||||||
} from '../../seed/core'
|
|
||||||
import { canBubbleUp } from './canBubbleUp'
|
import { canBubbleUp } from './canBubbleUp'
|
||||||
/* istanbul ignore if */
|
/* istanbul ignore if */
|
||||||
var hackSafari = Anot.modern && document.ontouchstart
|
var hackSafari = document.ontouchstart
|
||||||
|
|
||||||
//添加fn.bind, fn.unbind, bind, unbind
|
//添加fn.bind, fn.unbind, bind, unbind
|
||||||
Anot.fn.bind = function(type, fn, phase) {
|
Anot.fn.bind = function(type, fn, phase) {
|
||||||
|
@ -54,7 +45,7 @@ Anot.bind = function(elem, type, fn) {
|
||||||
/* istanbul ignore if */
|
/* istanbul ignore if */
|
||||||
if (value.indexOf(type + ':') === -1) {
|
if (value.indexOf(type + ':') === -1) {
|
||||||
//同一种事件只绑定一次
|
//同一种事件只绑定一次
|
||||||
if (canBubbleUp[type] || (Anot.modern && focusBlur[type])) {
|
if (canBubbleUp[type] || focusBlur[type]) {
|
||||||
delegateEvent(type)
|
delegateEvent(type)
|
||||||
} else {
|
} else {
|
||||||
Anot._nativeBind(elem, type, dispatch)
|
Anot._nativeBind(elem, type, dispatch)
|
||||||
|
@ -206,16 +197,14 @@ var eventProto = {
|
||||||
preventDefault: function() {
|
preventDefault: function() {
|
||||||
var e = this.originalEvent || {}
|
var e = this.originalEvent || {}
|
||||||
e.returnValue = this.returnValue = false
|
e.returnValue = this.returnValue = false
|
||||||
if (modern && e.preventDefault) {
|
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
}
|
|
||||||
},
|
},
|
||||||
stopPropagation: function() {
|
stopPropagation: function() {
|
||||||
var e = this.originalEvent || {}
|
var e = this.originalEvent || {}
|
||||||
e.cancelBubble = this.cancelBubble = true
|
e.cancelBubble = this.cancelBubble = true
|
||||||
if (modern && e.stopPropagation) {
|
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
}
|
|
||||||
},
|
},
|
||||||
stopImmediatePropagation: function() {
|
stopImmediatePropagation: function() {
|
||||||
this.stopPropagation()
|
this.stopPropagation()
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Anot, Cache, document, createFragment } from '../../seed/core'
|
import { Anot, Cache, createFragment } from '../../seed/core'
|
||||||
import { fromString } from '../../vtree/fromString'
|
import { fromString } from '../../vtree/fromString'
|
||||||
export { Anot }
|
export { Anot }
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Anot, window, document, root, inBrowser } from '../../seed/core'
|
import { Anot, root } from '../../seed/core'
|
||||||
|
|
||||||
var readyList = []
|
var readyList = []
|
||||||
|
|
||||||
|
@ -33,6 +33,4 @@ function bootstrap() {
|
||||||
Anot.bind(window, 'load', fireReady)
|
Anot.bind(window, 'load', fireReady)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inBrowser) {
|
bootstrap()
|
||||||
bootstrap()
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
//safari5+是把contains方法放在Element.prototype上而不是Node.prototype
|
//safari5+是把contains方法放在Element.prototype上而不是Node.prototype
|
||||||
import { Anot, document, window, root } from '../../seed/core'
|
import { Anot, root } from '../../seed/core'
|
||||||
import { fixContains } from './fixContains'
|
import { fixContains } from './fixContains'
|
||||||
export { Anot }
|
export { Anot }
|
||||||
|
|
||||||
|
@ -9,26 +9,25 @@ Anot.cloneNode = function(a) {
|
||||||
return a.cloneNode(true)
|
return a.cloneNode(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Anot.modern) {
|
if (!document.contains) {
|
||||||
if (!document.contains) {
|
|
||||||
Node.prototype.contains = function(child) {
|
Node.prototype.contains = function(child) {
|
||||||
//IE6-8没有Node对象
|
//IE6-8没有Node对象
|
||||||
return fixContains(this, child)
|
return fixContains(this, child)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function fixFF(prop, cb) {
|
function fixFF(prop, cb) {
|
||||||
//firefox12 http://caniuse.com/#search=outerHTML
|
//firefox12 http://caniuse.com/#search=outerHTML
|
||||||
if (!(prop in root)) {
|
if (!(prop in root)) {
|
||||||
HTMLElement.prototype.__defineGetter__(prop, cb)
|
HTMLElement.prototype.__defineGetter__(prop, cb)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fixFF('outerHTML', function() {
|
fixFF('outerHTML', function() {
|
||||||
//https://developer.mozilla.org/en-US/docs/Web/API/ParentNode/children
|
//https://developer.mozilla.org/en-US/docs/Web/API/ParentNode/children
|
||||||
var div = document.createElement('div')
|
var div = document.createElement('div')
|
||||||
div.appendChild(this)
|
div.appendChild(this)
|
||||||
return div.innerHTML
|
return div.innerHTML
|
||||||
})
|
})
|
||||||
fixFF('children', function() {
|
fixFF('children', function() {
|
||||||
var children = []
|
var children = []
|
||||||
for (var i = 0, el; (el = this.childNodes[i++]); ) {
|
for (var i = 0, el; (el = this.childNodes[i++]); ) {
|
||||||
if (el.nodeType === 1) {
|
if (el.nodeType === 1) {
|
||||||
|
@ -36,8 +35,7 @@ if (Anot.modern) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return children
|
return children
|
||||||
})
|
})
|
||||||
fixFF('innerText', function() {
|
fixFF('innerText', function() {
|
||||||
return this.textContent
|
return this.textContent
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
* ------------------------------------------------------------
|
* ------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { window } from '../seed/core'
|
|
||||||
let checker = {
|
let checker = {
|
||||||
TransitionEvent: 'transitionend',
|
TransitionEvent: 'transitionend',
|
||||||
WebKitTransitionEvent: 'webkitTransitionEnd',
|
WebKitTransitionEvent: 'webkitTransitionEnd',
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Anot, window, Cache } from '../seed/core'
|
import { Anot, Cache } from '../seed/core'
|
||||||
import { cssDiff } from '../directives/css'
|
import { cssDiff } from '../directives/css'
|
||||||
import {
|
import {
|
||||||
css3,
|
css3,
|
||||||
|
|
|
@ -1,37 +1,3 @@
|
||||||
/*
|
|
||||||
'yyyy': 4 digit representation of year (e.g. AD 1 => 0001, AD 2010 => 2010)
|
|
||||||
'yy': 2 digit representation of year, padded (00-99). (e.g. AD 2001 => 01, AD 2010 => 10)
|
|
||||||
'y': 1 digit representation of year, e.g. (AD 1 => 1, AD 199 => 199)
|
|
||||||
'MMMM': Month in year (January-December)
|
|
||||||
'MMM': Month in year (Jan-Dec)
|
|
||||||
'MM': Month in year, padded (01-12)
|
|
||||||
'M': Month in year (1-12)
|
|
||||||
'dd': Day in month, padded (01-31)
|
|
||||||
'd': Day in month (1-31)
|
|
||||||
'EEEE': Day in Week,(Sunday-Saturday)
|
|
||||||
'EEE': Day in Week, (Sun-Sat)
|
|
||||||
'HH': Hour in day, padded (00-23)
|
|
||||||
'H': Hour in day (0-23)
|
|
||||||
'hh': Hour in am/pm, padded (01-12)
|
|
||||||
'h': Hour in am/pm, (1-12)
|
|
||||||
'mm': Minute in hour, padded (00-59)
|
|
||||||
'm': Minute in hour (0-59)
|
|
||||||
'ss': Second in minute, padded (00-59)
|
|
||||||
's': Second in minute (0-59)
|
|
||||||
'a': am/pm marker
|
|
||||||
'Z': 4 digit (+sign) representation of the timezone offset (-1200-+1200)
|
|
||||||
format string can also be one of the following predefined localizable formats:
|
|
||||||
|
|
||||||
'medium': equivalent to 'MMM d, y h:mm:ss a' for en_US locale (e.g. Sep 3, 2010 12:05:08 pm)
|
|
||||||
'short': equivalent to 'M/d/yy h:mm a' for en_US locale (e.g. 9/3/10 12:05 pm)
|
|
||||||
'fullDate': equivalent to 'EEEE, MMMM d,y' for en_US locale (e.g. Friday, September 3, 2010)
|
|
||||||
'longDate': equivalent to 'MMMM d, y' for en_US locale (e.g. September 3, 2010
|
|
||||||
'mediumDate': equivalent to 'MMM d, y' for en_US locale (e.g. Sep 3, 2010)
|
|
||||||
'shortDate': equivalent to 'M/d/yy' for en_US locale (e.g. 9/3/10)
|
|
||||||
'mediumTime': equivalent to 'h:mm:ss a' for en_US locale (e.g. 12:05:08 pm)
|
|
||||||
'shortTime': equivalent to 'h:mm a' for en_US locale (e.g. 12:05 pm)
|
|
||||||
*/
|
|
||||||
|
|
||||||
function toInt(str) {
|
function toInt(str) {
|
||||||
return parseInt(str, 10) || 0
|
return parseInt(str, 10) || 0
|
||||||
}
|
}
|
||||||
|
@ -44,8 +10,12 @@ function padNumber(num, digits, trim) {
|
||||||
num = -num
|
num = -num
|
||||||
}
|
}
|
||||||
num = '' + num
|
num = '' + num
|
||||||
while (num.length < digits) num = '0' + num
|
while (num.length < digits) {
|
||||||
if (trim) num = num.substr(num.length - digits)
|
num = '0' + num
|
||||||
|
}
|
||||||
|
if (trim) {
|
||||||
|
num = num.substr(num.length - digits)
|
||||||
|
}
|
||||||
return neg + num
|
return neg + num
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Anot, msie, Cache } from '../seed/core'
|
import { Anot, Cache } 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 = Anot.oneObject(
|
||||||
|
@ -105,18 +105,6 @@ export function makeHandle(body) {
|
||||||
if (rhandleName.test(body)) {
|
if (rhandleName.test(body)) {
|
||||||
body = body + '($event)'
|
body = body + '($event)'
|
||||||
}
|
}
|
||||||
/* istanbul ignore if */
|
|
||||||
if (msie < 9) {
|
|
||||||
body = body.replace(rfixIE678, function(a, b, c) {
|
|
||||||
return (
|
|
||||||
'__vmodel__.' +
|
|
||||||
b +
|
|
||||||
'.call(__vmodel__' +
|
|
||||||
(/\S/.test(c) ? ',' + c : '') +
|
|
||||||
')'
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return body
|
return body
|
||||||
}
|
}
|
||||||
export function createGetter(expr, type) {
|
export function createGetter(expr, type) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Anot, inBrowser } from '../seed/core'
|
import { Anot } from '../seed/core'
|
||||||
|
|
||||||
import { Action, protectedMenbers } from '../vmodel/Action'
|
import { Action, protectedMenbers } from '../vmodel/Action'
|
||||||
|
|
||||||
|
@ -11,13 +11,13 @@ import { Action, protectedMenbers } from '../vmodel/Action'
|
||||||
export function Directive(vm, binding, vdom, render) {
|
export function Directive(vm, binding, vdom, render) {
|
||||||
var type = binding.type
|
var type = binding.type
|
||||||
var decorator = Anot.directives[type]
|
var decorator = Anot.directives[type]
|
||||||
if (inBrowser) {
|
|
||||||
var dom = Anot.vdom(vdom, 'toDOM')
|
var dom = Anot.vdom(vdom, 'toDOM')
|
||||||
if (dom.nodeType === 1) {
|
if (dom.nodeType === 1) {
|
||||||
dom.removeAttribute(binding.attrName)
|
dom.removeAttribute(binding.attrName)
|
||||||
}
|
}
|
||||||
vdom.dom = dom
|
vdom.dom = dom
|
||||||
}
|
|
||||||
var callback = decorator.update
|
var callback = decorator.update
|
||||||
? function(value) {
|
? function(value) {
|
||||||
if (!render.mount && /css|visible|duplex/.test(type)) {
|
if (!render.mount && /css|visible|duplex/.test(type)) {
|
||||||
|
|
|
@ -1,10 +1,4 @@
|
||||||
import {
|
import { Anot, config, delayCompileNodes, directives } from '../seed/core'
|
||||||
Anot,
|
|
||||||
config,
|
|
||||||
inBrowser,
|
|
||||||
delayCompileNodes,
|
|
||||||
directives
|
|
||||||
} from '../seed/core'
|
|
||||||
import { fromDOM } from '../vtree/fromDOM'
|
import { fromDOM } from '../vtree/fromDOM'
|
||||||
import { fromString } from '../vtree/fromString'
|
import { fromString } from '../vtree/fromString'
|
||||||
|
|
||||||
|
@ -173,11 +167,11 @@ Render.prototype = {
|
||||||
//推算出指令类型
|
//推算出指令类型
|
||||||
var type = dirs['ms-important'] === $id ? 'important' : 'controller'
|
var type = dirs['ms-important'] === $id ? 'important' : 'controller'
|
||||||
//推算出用户定义时属性名,是使用ms-属性还是:属性
|
//推算出用户定义时属性名,是使用ms-属性还是:属性
|
||||||
var attrName = 'ms-' + type in attrs ? 'ms-' + type : ':' + type
|
var _tmp = 'ms-' + type
|
||||||
|
var attrName = _tmp in attrs ? _tmp : ':' + type
|
||||||
|
|
||||||
if (inBrowser) {
|
|
||||||
delete attrs[attrName]
|
delete attrs[attrName]
|
||||||
}
|
|
||||||
var dir = directives[type]
|
var dir = directives[type]
|
||||||
scope = dir.getScope.call(this, $id, scope)
|
scope = dir.getScope.call(this, $id, scope)
|
||||||
if (!scope) {
|
if (!scope) {
|
||||||
|
@ -237,13 +231,11 @@ Render.prototype = {
|
||||||
complete() {
|
complete() {
|
||||||
this.yieldDirectives()
|
this.yieldDirectives()
|
||||||
this.beforeReady()
|
this.beforeReady()
|
||||||
if (inBrowser) {
|
|
||||||
var root = this.root
|
var root = this.root
|
||||||
if (inBrowser) {
|
|
||||||
var rootDom = Anot.vdom(root, 'toDOM')
|
var rootDom = Anot.vdom(root, 'toDOM')
|
||||||
groupTree(rootDom, root.children)
|
groupTree(rootDom, root.children)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.mount = true
|
this.mount = true
|
||||||
var fn
|
var fn
|
||||||
|
@ -271,9 +263,9 @@ Render.prototype = {
|
||||||
}
|
}
|
||||||
for (var i = 0, binding; (binding = bindings[i++]); ) {
|
for (var i = 0, binding; (binding = bindings[i++]); ) {
|
||||||
var dir = directives[binding.type]
|
var dir = directives[binding.type]
|
||||||
if (!inBrowser && /on|duplex|active|hover/.test(binding.type)) {
|
// if (!inBrowser && /on|duplex|active|hover/.test(binding.type)) {
|
||||||
continue
|
// continue
|
||||||
}
|
// }
|
||||||
if (dir.beforeInit) {
|
if (dir.beforeInit) {
|
||||||
dir.beforeInit.call(binding)
|
dir.beforeInit.call(binding)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,32 +0,0 @@
|
||||||
export let win =
|
|
||||||
typeof window === 'object' ? window : typeof global === 'object' ? global : {}
|
|
||||||
|
|
||||||
export let inBrowser = !!win.location && win.navigator
|
|
||||||
/* istanbul ignore if */
|
|
||||||
|
|
||||||
export let document = inBrowser
|
|
||||||
? win.document
|
|
||||||
: {
|
|
||||||
createElement: Object,
|
|
||||||
createElementNS: Object,
|
|
||||||
documentElement: 'xx',
|
|
||||||
contains: Boolean
|
|
||||||
}
|
|
||||||
export var root = inBrowser
|
|
||||||
? document.documentElement
|
|
||||||
: {
|
|
||||||
outerHTML: 'x'
|
|
||||||
}
|
|
||||||
|
|
||||||
let versions = {
|
|
||||||
objectobject: 7, //IE7-8
|
|
||||||
objectundefined: 6, //IE6
|
|
||||||
undefinedfunction: NaN, // other modern browsers
|
|
||||||
undefinedobject: NaN //Mobile Safari 8.0.0 (iOS 8.4.0)
|
|
||||||
//objectfunction chrome 47
|
|
||||||
}
|
|
||||||
/* istanbul ignore next */
|
|
||||||
export var msie =
|
|
||||||
document.documentMode || versions[typeof document.all + typeof XMLHttpRequest]
|
|
||||||
|
|
||||||
export var modern = /NaN|undefined/.test(msie) || msie > 8
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { win, document, msie, inBrowser, root, modern } from './browser'
|
|
||||||
import { Cache } from './cache'
|
import { Cache } from './cache'
|
||||||
import { directive, directives, delayCompileNodes } from './directive'
|
import { directive, directives, delayCompileNodes } from './directive'
|
||||||
|
|
||||||
export var window = win
|
const root = document.documentElement
|
||||||
|
|
||||||
export function Anot(el) {
|
export function Anot(el) {
|
||||||
return new Anot.init(el)
|
return new Anot.init(el)
|
||||||
}
|
}
|
||||||
|
@ -53,17 +53,7 @@ export function log() {
|
||||||
Function.apply.call(console.log, console, arguments)
|
Function.apply.call(console.log, console, arguments)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export {
|
export { Cache, directive, directives, delayCompileNodes, root }
|
||||||
Cache,
|
|
||||||
directive,
|
|
||||||
directives,
|
|
||||||
delayCompileNodes,
|
|
||||||
document,
|
|
||||||
root,
|
|
||||||
msie,
|
|
||||||
modern,
|
|
||||||
inBrowser
|
|
||||||
}
|
|
||||||
export function warn() {
|
export function warn() {
|
||||||
if (hasConsole && Anot.config.debug) {
|
if (hasConsole && Anot.config.debug) {
|
||||||
var method = console.warn || console.log
|
var method = console.warn || console.log
|
||||||
|
@ -274,12 +264,9 @@ shadowCopy(Anot, {
|
||||||
error,
|
error,
|
||||||
config,
|
config,
|
||||||
|
|
||||||
modern,
|
|
||||||
msie,
|
|
||||||
root,
|
root,
|
||||||
document,
|
document,
|
||||||
window,
|
window,
|
||||||
inBrowser,
|
|
||||||
|
|
||||||
isObject,
|
isObject,
|
||||||
range,
|
range,
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import { document } from '../seed/core'
|
|
||||||
|
|
||||||
export function VComment(text) {
|
export function VComment(text) {
|
||||||
this.nodeName = '#comment'
|
this.nodeName = '#comment'
|
||||||
this.nodeValue = text
|
this.nodeValue = text
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Anot, document } from '../seed/core'
|
import { Anot } from '../seed/core'
|
||||||
|
|
||||||
export function VElement(type, props, children, isVoidTag) {
|
export function VElement(type, props, children, isVoidTag) {
|
||||||
this.nodeName = type
|
this.nodeName = type
|
||||||
|
@ -12,7 +12,7 @@ VElement.prototype = {
|
||||||
if (this.dom) return this.dom
|
if (this.dom) return this.dom
|
||||||
var dom,
|
var dom,
|
||||||
tagName = this.nodeName
|
tagName = this.nodeName
|
||||||
if (Anot.modern && svgTags[tagName]) {
|
if (svgTags[tagName]) {
|
||||||
dom = createSVG(tagName)
|
dom = createSVG(tagName)
|
||||||
} else {
|
} else {
|
||||||
dom = document.createElement(tagName)
|
dom = document.createElement(tagName)
|
||||||
|
@ -89,6 +89,4 @@ var svgTags = Anot.oneObject(
|
||||||
'path,polygon,polyline,rect,symbol,text,use,g,svg'
|
'path,polygon,polyline,rect,symbol,text,use,g,svg'
|
||||||
)
|
)
|
||||||
|
|
||||||
if (Anot.inBrowser) {
|
var supportTemplate = 'content' in document.createElement('template')
|
||||||
var supportTemplate = 'content' in document.createElement('template')
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Anot, document } from '../seed/core'
|
import { Anot } from '../seed/core'
|
||||||
|
|
||||||
export function VText(text) {
|
export function VText(text) {
|
||||||
this.nodeName = '#text'
|
this.nodeName = '#text'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Anot, ap, platform, modern, isObject } from '../seed/core'
|
import { Anot, ap, platform, isObject } from '../seed/core'
|
||||||
import { Mutation } from './Mutation'
|
import { Mutation } from './Mutation'
|
||||||
|
|
||||||
var _splice = ap.splice
|
var _splice = ap.splice
|
||||||
|
@ -102,9 +102,9 @@ __method__.forEach(function(method) {
|
||||||
export function listFactory(array, stop, dd) {
|
export function listFactory(array, stop, dd) {
|
||||||
if (!stop) {
|
if (!stop) {
|
||||||
hijackMethods(array)
|
hijackMethods(array)
|
||||||
if (modern) {
|
|
||||||
Object.defineProperty(array, '$model', platform.modelAccessor)
|
Object.defineProperty(array, '$model', platform.modelAccessor)
|
||||||
}
|
|
||||||
platform.hideProperty(array, '$hashcode', Anot.makeHashCode('$'))
|
platform.hideProperty(array, '$hashcode', Anot.makeHashCode('$'))
|
||||||
platform.hideProperty(array, '$events', { __dep__: dd || new Mutation() })
|
platform.hideProperty(array, '$events', { __dep__: dd || new Mutation() })
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Anot, platform, modern } from '../seed/core'
|
import { Anot, platform } from '../seed/core'
|
||||||
import { $$skipArray } from './reserved'
|
import { $$skipArray } from './reserved'
|
||||||
import { Action } from './Action'
|
import { Action } from './Action'
|
||||||
import './share'
|
import './share'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Anot, platform, isObject, modern } from '../seed/core'
|
import { Anot, platform, isObject } 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'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Anot, platform, isObject, modern } from '../seed/core'
|
import { Anot, platform, isObject } 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'
|
||||||
|
|
Reference in New Issue