This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
bytedo
/
wcui
Archived
1
0
Fork 0

重命名基础样式文件;优化框架组件机制,支持slot重复,支持特殊值向组件同步;优化指令回调;移除repeat的排序功能;

old
宇天 2018-06-12 21:55:46 +08:00
parent fc957104ff
commit 8ed9ecd462
13 changed files with 444 additions and 309 deletions

View File

@ -4,18 +4,13 @@ const log = console.log
const fs = require('iofs')
const path = require('path')
const scss = require('node-sass')
const postcss = require('postcss')
const autoprefixer = require('autoprefixer')
const chalk = require('chalk')
const uglify = require('uglify-es')
const sourceDir = path.resolve(__dirname, 'src')
const buildDir = path.resolve(__dirname, 'dist')
const prefixer = postcss().use(
autoprefixer({
browsers: ['ie > 9', 'iOS > 8', 'Android >= 4.4', 'ff > 38', 'Chrome > 38']
})
)
const cssOpt = {
includePaths: ['src/css/'],
outputStyle: 'compressed'
@ -79,8 +74,8 @@ if (fs.isdir(buildDir)) {
// css目录
cssFiles.forEach(file => {
if (/\.scss$/.test(file)) {
let entry = path.resolve(sourceDir, 'css/', file)
let output = path.resolve(buildDir, 'css/', file.replace(/scss$/, 'css'))
let entry = file
let output = file.replace('src/css', 'dist/css').replace(/scss$/, 'css')
compileCss(entry, output)
}
@ -88,8 +83,8 @@ cssFiles.forEach(file => {
// js目录的处理要复杂一点
jsFiles.forEach(file => {
let entry = path.resolve(sourceDir, 'js', file)
let output = path.resolve(buildDir, 'js', file)
let entry = file
let output = file.replace(/src\/js/, 'dist/js').replace(/scss$/, 'css')
let ext = file.slice(file.lastIndexOf('.') + 1)
switch (ext) {
@ -97,7 +92,6 @@ jsFiles.forEach(file => {
compileJs(entry, output)
break
case 'scss':
output = output.replace(/scss$/, 'css')
compileCss(entry, output)
break
case 'htm':

View File

@ -93,8 +93,8 @@ if (fs.isdir(buildDir)) {
// css目录
cssFiles.forEach(file => {
if (/\.scss$/.test(file)) {
let entry = path.resolve(sourceDir, 'css/', file)
let output = path.resolve(buildDir, 'css/', file.replace(/scss$/, 'css'))
let entry = file
let output = file.replace('src/css', 'dist/css').replace(/scss$/, 'css')
compileCss(entry, output)
}
@ -102,8 +102,8 @@ cssFiles.forEach(file => {
// js目录的处理要复杂一点
jsFiles.forEach(file => {
let entry = path.resolve(sourceDir, 'js', file)
let output = path.resolve(buildDir, 'js', file)
let entry = file
let output = file.replace(/src\/js/, 'dist/js').replace(/scss$/, 'css')
let ext = file.slice(file.lastIndexOf('.') + 1)
switch (ext) {
@ -111,7 +111,6 @@ jsFiles.forEach(file => {
compileJs(entry, output)
break
case 'scss':
output = output.replace(/scss$/, 'css')
compileCss(entry, output)
break
case 'htm':

View File

@ -21,14 +21,14 @@
"dependencies": {
"autoprefixer": "^7.2.6",
"babel-core": "^6.26.3",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-decorators-legacy": "^1.3.5",
"babel-plugin-transform-es2015-classes": "^6.24.1",
"babel-plugin-transform-es2015-for-of": "^6.23.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"chalk": "^2.4.1",
"chokidar": "^1.7.0",
"iofs": "^1.0.3",
"iofs": "^1.1.0",
"node-sass": "^4.9.0",
"postcss": "^6.0.22",
"uglify-es": "^3.3.9"

File diff suppressed because one or more lines are too long

View File

@ -39,7 +39,7 @@ a:focus,input,button:focus,input:focus {outline:none;}
::-moz-focus-inner {
border:none;outline:none;
}
[anot],[\:if],do-* {visibility:hidden;}
[anot],[\:if] {visibility:hidden;}
.do-fn-cl { *zoom: 1; }
.do-fn-cl::after { content: "."; display: block; height: 0; clear: both; visibility: hidden; overflow:hidden;}

File diff suppressed because one or more lines are too long

View File

@ -225,15 +225,15 @@ const _Anot = (function() {
if ($elem === DOC.body) {
scanTag($elem, [])
} else {
var $parent = $elem
while (($parent = $parent.parentNode)) {
if ($parent.anotctrl) {
var _parent = $elem
while ((_parent = _parent.parentNode)) {
if (_parent.anotctrl) {
break
}
}
scanTag(
$elem.parentNode,
$parent ? [VMODELS[$parent.anotctrl]] : []
_parent ? [VMODELS[_parent.anotctrl]] : []
)
}
}
@ -1456,6 +1456,7 @@ const _Anot = (function() {
function $emit(key, args) {
var event = this.$events
var _parent = null
if (event && event[key]) {
if (args) {
args[2] = key
@ -1469,22 +1470,22 @@ const _Anot = (function() {
} catch (e) {}
}
}
var parent = this.$up
if (parent) {
_parent = this.$up
if (_parent) {
if (this.$pathname) {
$emit.call(parent, this.$pathname + '.' + key, args) //以确切的值往上冒泡
$emit.call(_parent, this.$pathname + '.' + key, args) //以确切的值往上冒泡
}
$emit.call(parent, '*.' + key, args) //以模糊的值往上冒泡
$emit.call(_parent, '*.' + key, args) //以模糊的值往上冒泡
}
} else {
parent = this.$up
_parent = this.$up
if (this.$ups) {
for (var i in this.$ups) {
$emit.call(this.$ups[i], i + '.' + key, args) //以确切的值往上冒泡
}
return
}
if (parent) {
if (_parent) {
var p = this.$pathname
if (p === '') p = '*'
var path = p + '.' + key
@ -1493,11 +1494,11 @@ const _Anot = (function() {
args = (args && args.concat([path, key])) || [path, key]
if (arr.indexOf('*') === -1) {
$emit.call(parent, path, args) //以确切的值往上冒泡
$emit.call(_parent, path, args) //以确切的值往上冒泡
arr[1] = '*'
$emit.call(parent, arr.join('.'), args) //以模糊的值往上冒泡
$emit.call(_parent, arr.join('.'), args) //以模糊的值往上冒泡
} else {
$emit.call(parent, path, args) //以确切的值往上冒泡
$emit.call(_parent, path, args) //以确切的值往上冒泡
}
}
}
@ -1743,6 +1744,12 @@ const _Anot = (function() {
var v = $vmodel.$children[i]
v.$fire && v.$fire.apply(v, [ee, a])
}
// component! 这是一个特殊的标识,可以直接修改子组件的state值
} else if (path.indexOf('component!') === 0) {
var ee = path.slice(10)
for (var i in $vmodel.$children) {
$vmodel.$children[i][ee] = a
}
} else {
$emit.call($vmodel, path, [a])
}
@ -2758,9 +2765,9 @@ const _Anot = (function() {
}
array.push(obj)
}
var parent = node.parentNode
if (parent && parent.nodeType === 1) {
showHidden(parent, array)
var _parent = node.parentNode
if (_parent && _parent.nodeType === 1) {
showHidden(_parent, array)
}
}
}
@ -3339,12 +3346,16 @@ const _Anot = (function() {
var rnoCollect = /^(:\S+|data-\S+|on[a-z]+|id|style|class)$/
var ronattr = '__fn__'
var specifiedVars = [':disabled', ':loading']
function getOptionsFromTag(elem, vmodels) {
var attributes = elem.attributes
var attributes = aslice.call(elem.attributes, 0)
var ret = {}
for (var i = 0, attr; (attr = attributes[i++]); ) {
var name = attr.name
if (attr.specified && !rnoCollect.test(name)) {
if (
(attr.specified && !rnoCollect.test(name)) ||
specifiedVars.includes(name)
) {
if (name.indexOf(ronattr) === 0) {
name = attr.value.slice(6)
ret[name] = elem[attr.value]
@ -3364,6 +3375,7 @@ const _Anot = (function() {
} else {
ret[camelizeName] = parseData(attr.value)
}
elem.removeAttribute(name)
}
}
}
@ -3739,8 +3751,9 @@ const _Anot = (function() {
arr.forEach(function(elem) {
var slot = elem.getAttribute('slot')
if (slot) {
obj[slot] = obj[slot] || []
elem.removeAttribute('slot')
obj[slot] = elem.outerHTML
obj[slot].push(elem.outerHTML)
}
})
return obj
@ -3771,6 +3784,8 @@ const _Anot = (function() {
//如果还没有解析完,就延迟一下 #1155
return
}
var parentVm = host.vmodels[0]
var state = {}
var props = getOptionsFromTag(elem, host.vmodels)
var $id = props.uuid || generateID(widget)
var __willpush__ = null
@ -3778,7 +3793,24 @@ const _Anot = (function() {
if (props.hasOwnProperty('hostPush')) {
elem.removeAttribute('host-push')
__willpush__ = props.hostPush
props.hostPush = host.vmodels[0][__willpush__]
props.hostPush = parentVm[__willpush__]
}
if (props.hasOwnProperty(':disabled')) {
var disabledKey = props[':disabled']
state.disabled = parentVm[disabledKey]
parentVm.$watch(disabledKey, function(val) {
parentVm.$fire('component!disabled', val)
})
delete props[':disabled']
}
if (props.hasOwnProperty(':loading')) {
var loadingKey = props[':loading']
state.loading = parentVm[loadingKey]
parentVm.$watch(loadingKey, function(val) {
parentVm.$fire('component!loading', val)
})
delete props[':loading']
}
delete props.uuid
@ -3788,6 +3820,7 @@ const _Anot = (function() {
hooks.state = hooks.state || {}
Object.assign(hooks.props, props)
Object.assign(hooks.state, state)
hooks.construct.call(elem, hooks.props, hooks.state)
@ -3810,13 +3843,13 @@ const _Anot = (function() {
var vmodel = Anot(hooks)
delete vmodel.$mounted
host.vmodels[0].$children.push(vmodel)
parentVm.$children.push(vmodel)
elem.msResolved = 1 //防止二进扫描此元素
if (__willpush__) {
hideProperty(vmodel, '$push', function(val) {
host.vmodels[0][__willpush__] = val
parentVm[__willpush__] = val
})
}
@ -3988,12 +4021,12 @@ const _Anot = (function() {
effectBinding(elem, binding)
binding.includeRendered = getBindingCallback(
elem,
'data-include-rendered',
'data-rendered',
binding.vmodels
)
binding.includeLoaded = getBindingCallback(
elem,
'data-include-loaded',
'data-loaded',
binding.vmodels
)
var outer = (binding.includeReplace = !!Anot(elem).data(
@ -4057,10 +4090,10 @@ const _Anot = (function() {
//chrome v37- 下embed标签动态设置的src无法发起请求
if (window.chrome && elem.tagName === 'EMBED') {
var parent = elem.parentNode
var _parent = elem.parentNode
var com = DOC.createComment(':src')
parent.replaceChild(com, elem)
parent.replaceChild(elem, com)
_parent.replaceChild(com, elem)
_parent.replaceChild(elem, com)
}
} else {
var k = i
@ -4375,7 +4408,7 @@ const _Anot = (function() {
var elem = binding.element
var vmodels = binding.vmodels
binding.changed =
getBindingCallback(elem, 'data-duplex-changed', vmodels) || noop
getBindingCallback(elem, 'data-changed', vmodels) || noop
var params = []
var casting = oneObject('string,number,boolean,checked')
if (elem.type === 'radio' && binding.param === '') {
@ -4995,12 +5028,12 @@ const _Anot = (function() {
Anot.mix(Anot.effect, {
apply: applyEffect,
append: function(el, parent, after, opts) {
append: function(el, _parent, after, opts) {
return applyEffect(
el,
1,
function() {
parent.appendChild(el)
_parent.appendChild(el)
},
after,
opts
@ -5017,12 +5050,12 @@ const _Anot = (function() {
opts
)
},
remove: function(el, parent, after, opts) {
remove: function(el, _parent, after, opts) {
return applyEffect(
el,
0,
function() {
if (el.parentNode === parent) parent.removeChild(el)
if (el.parentNode === _parent) _parent.removeChild(el)
},
after,
opts
@ -5035,15 +5068,15 @@ const _Anot = (function() {
var binding = this
var elem = this.element
var isHtmlFilter = elem.nodeType !== 1
var parent = isHtmlFilter ? elem.parentNode : elem
if (!parent) return
var _parent = isHtmlFilter ? elem.parentNode : elem
if (!_parent) return
val = val == null ? '' : val
if (elem.nodeType === 3) {
var signature = generateID('html')
parent.insertBefore(DOC.createComment(signature), elem)
_parent.insertBefore(DOC.createComment(signature), elem)
binding.element = DOC.createComment(signature + ':end')
parent.replaceChild(binding.element, elem)
_parent.replaceChild(binding.element, elem)
elem = binding.element
}
if (typeof val !== 'object') {
@ -5069,10 +5102,10 @@ const _Anot = (function() {
if (!node || (node.nodeType === 8 && node.nodeValue === endValue)) {
break
} else {
parent.removeChild(node)
_parent.removeChild(node)
}
}
parent.insertBefore(fragment, elem)
_parent.insertBefore(fragment, elem)
} else {
Anot.clearHTML(elem).appendChild(fragment)
}
@ -5430,14 +5463,9 @@ const _Anot = (function() {
elem.removeAttribute(binding.name)
effectBinding(elem, binding)
binding.param = binding.param || 'el'
binding.sortedCallback = getBindingCallback(
elem,
'data-repeat-sortby',
binding.vmodels
)
var rendered = getBindingCallback(
elem,
'data-repeat-rendered',
'data-rendered',
binding.vmodels
)
@ -5448,18 +5476,18 @@ const _Anot = (function() {
binding.start = start
binding.template = anotFragment.cloneNode(false)
var parent = elem.parentNode
parent.replaceChild(end, elem)
parent.insertBefore(start, end)
var _parent = elem.parentNode
_parent.replaceChild(end, elem)
_parent.insertBefore(start, end)
binding.template.appendChild(elem)
binding.element = end
if (rendered) {
var removeFn = Anot.bind(parent, 'datasetchanged', function() {
rendered.apply(parent, parent.args)
Anot.unbind(parent, 'datasetchanged', removeFn)
parent.msRendered = rendered
var removeFn = Anot.bind(_parent, 'datasetchanged', function() {
rendered.apply(_parent, _parent.args)
Anot.unbind(_parent, 'datasetchanged', removeFn)
_parent.msRendered = rendered
})
}
}
@ -5486,14 +5514,6 @@ const _Anot = (function() {
}
}
var track = this.track
if (binding.sortedCallback) {
//如果有回调,则让它们排序
var keys2 = binding.sortedCallback.call(parent, track)
if (keys2 && Array.isArray(keys2)) {
track = keys2
}
}
var action = 'move'
binding.$repeat = value
var fragments = []
@ -5504,7 +5524,7 @@ const _Anot = (function() {
var elem = this.element
var length = track.length
var parent = elem.parentNode
var _parent = elem.parentNode
//检查新元素数量
var newCount = 0
@ -5523,7 +5543,7 @@ const _Anot = (function() {
if (clear) {
while (kill !== start) {
parent.removeChild(kill)
_parent.removeChild(kill)
kill = elem.previousSibling
}
}
@ -5585,7 +5605,7 @@ const _Anot = (function() {
}
this.proxies = proxies
if (init && !binding.effectDriver) {
parent.insertBefore(transation, elem)
_parent.insertBefore(transation, elem)
fragments.forEach(function(fragment) {
scanNodeArray(fragment.nodes || [], fragment.vmodels)
//if(fragment.vmodels.length > 2)
@ -5617,7 +5637,7 @@ const _Anot = (function() {
staggerIndex = mayStaggerAnimate(
binding.effectEnterStagger,
function() {
parent.insertBefore(
_parent.insertBefore(
fragment.content,
preElement.nextSibling
)
@ -5637,7 +5657,7 @@ const _Anot = (function() {
function() {
var curNode = removeItem(proxy2.$anchor)
var inserted = Anot.slice(curNode.childNodes)
parent.insertBefore(curNode, preElement.nextSibling)
_parent.insertBefore(curNode, preElement.nextSibling)
animateRepeat(inserted, 1, binding)
},
staggerIndex
@ -5655,17 +5675,17 @@ const _Anot = (function() {
//repeat --> duplex
;(function(args) {
parent.args = args
if (parent.msRendered) {
_parent.args = args
if (_parent.msRendered) {
//第一次事件触发,以后直接调用
parent.msRendered.apply(parent, args)
_parent.msRendered.apply(_parent, args)
}
})(kernel.newWatch ? arguments : [action])
var id = setTimeout(function() {
clearTimeout(id)
//触发上层的select回调及自己的rendered回调
Anot.fireDom(parent, 'datasetchanged', {
bubble: parent.msHasEvent
Anot.fireDom(_parent, 'datasetchanged', {
bubble: _parent.msHasEvent
})
})
this.enterCount -= 1

View File

@ -240,15 +240,15 @@
if ($elem === DOC.body) {
scanTag($elem, [])
} else {
var $parent = $elem
while (($parent = $parent.parentNode)) {
if ($parent.anotctrl) {
var _parent = $elem
while ((_parent = _parent.parentNode)) {
if (_parent.anotctrl) {
break
}
}
scanTag(
$elem.parentNode,
$parent ? [VMODELS[$parent.anotctrl]] : []
_parent ? [VMODELS[_parent.anotctrl]] : []
)
}
}
@ -1471,6 +1471,7 @@
function $emit(key, args) {
var event = this.$events
var _parent = null
if (event && event[key]) {
if (args) {
args[2] = key
@ -1484,22 +1485,22 @@
} catch (e) {}
}
}
var parent = this.$up
if (parent) {
_parent = this.$up
if (_parent) {
if (this.$pathname) {
$emit.call(parent, this.$pathname + '.' + key, args) //以确切的值往上冒泡
$emit.call(_parent, this.$pathname + '.' + key, args) //以确切的值往上冒泡
}
$emit.call(parent, '*.' + key, args) //以模糊的值往上冒泡
$emit.call(_parent, '*.' + key, args) //以模糊的值往上冒泡
}
} else {
parent = this.$up
_parent = this.$up
if (this.$ups) {
for (var i in this.$ups) {
$emit.call(this.$ups[i], i + '.' + key, args) //以确切的值往上冒泡
}
return
}
if (parent) {
if (_parent) {
var p = this.$pathname
if (p === '') p = '*'
var path = p + '.' + key
@ -1508,11 +1509,11 @@
args = (args && args.concat([path, key])) || [path, key]
if (arr.indexOf('*') === -1) {
$emit.call(parent, path, args) //以确切的值往上冒泡
$emit.call(_parent, path, args) //以确切的值往上冒泡
arr[1] = '*'
$emit.call(parent, arr.join('.'), args) //以模糊的值往上冒泡
$emit.call(_parent, arr.join('.'), args) //以模糊的值往上冒泡
} else {
$emit.call(parent, path, args) //以确切的值往上冒泡
$emit.call(_parent, path, args) //以确切的值往上冒泡
}
}
}
@ -1758,6 +1759,12 @@
var v = $vmodel.$children[i]
v.$fire && v.$fire.apply(v, [ee, a])
}
// component! 这是一个特殊的标识,可以直接修改子组件的state值
} else if (path.indexOf('component!') === 0) {
var ee = path.slice(10)
for (var i in $vmodel.$children) {
$vmodel.$children[i][ee] = a
}
} else {
$emit.call($vmodel, path, [a])
}
@ -2773,9 +2780,9 @@
}
array.push(obj)
}
var parent = node.parentNode
if (parent && parent.nodeType === 1) {
showHidden(parent, array)
var _parent = node.parentNode
if (_parent && _parent.nodeType === 1) {
showHidden(_parent, array)
}
}
}
@ -3354,12 +3361,16 @@
var rnoCollect = /^(:\S+|data-\S+|on[a-z]+|id|style|class)$/
var ronattr = '__fn__'
var specifiedVars = [':disabled', ':loading']
function getOptionsFromTag(elem, vmodels) {
var attributes = elem.attributes
var attributes = aslice.call(elem.attributes, 0)
var ret = {}
for (var i = 0, attr; (attr = attributes[i++]); ) {
var name = attr.name
if (attr.specified && !rnoCollect.test(name)) {
if (
(attr.specified && !rnoCollect.test(name)) ||
specifiedVars.includes(name)
) {
if (name.indexOf(ronattr) === 0) {
name = attr.value.slice(6)
ret[name] = elem[attr.value]
@ -3379,6 +3390,7 @@
} else {
ret[camelizeName] = parseData(attr.value)
}
elem.removeAttribute(name)
}
}
}
@ -3754,8 +3766,9 @@
arr.forEach(function(elem) {
var slot = elem.getAttribute('slot')
if (slot) {
obj[slot] = obj[slot] || []
elem.removeAttribute('slot')
obj[slot] = elem.outerHTML
obj[slot].push(elem.outerHTML)
}
})
return obj
@ -3786,6 +3799,8 @@
//如果还没有解析完,就延迟一下 #1155
return
}
var parentVm = host.vmodels[0]
var state = {}
var props = getOptionsFromTag(elem, host.vmodels)
var $id = props.uuid || generateID(widget)
var __willpush__ = null
@ -3793,7 +3808,24 @@
if (props.hasOwnProperty('hostPush')) {
elem.removeAttribute('host-push')
__willpush__ = props.hostPush
props.hostPush = host.vmodels[0][__willpush__]
props.hostPush = parentVm[__willpush__]
}
if (props.hasOwnProperty(':disabled')) {
var disabledKey = props[':disabled']
state.disabled = parentVm[disabledKey]
parentVm.$watch(disabledKey, function(val) {
parentVm.$fire('component!disabled', val)
})
delete props[':disabled']
}
if (props.hasOwnProperty(':loading')) {
var loadingKey = props[':loading']
state.loading = parentVm[loadingKey]
parentVm.$watch(loadingKey, function(val) {
parentVm.$fire('component!loading', val)
})
delete props[':loading']
}
delete props.uuid
@ -3803,6 +3835,7 @@
hooks.state = hooks.state || {}
Object.assign(hooks.props, props)
Object.assign(hooks.state, state)
hooks.construct.call(elem, hooks.props, hooks.state)
@ -3825,13 +3858,13 @@
var vmodel = Anot(hooks)
delete vmodel.$mounted
host.vmodels[0].$children.push(vmodel)
parentVm.$children.push(vmodel)
elem.msResolved = 1 //防止二进扫描此元素
if (__willpush__) {
hideProperty(vmodel, '$push', function(val) {
host.vmodels[0][__willpush__] = val
parentVm[__willpush__] = val
})
}
@ -4003,12 +4036,12 @@
effectBinding(elem, binding)
binding.includeRendered = getBindingCallback(
elem,
'data-include-rendered',
'data-rendered',
binding.vmodels
)
binding.includeLoaded = getBindingCallback(
elem,
'data-include-loaded',
'data-loaded',
binding.vmodels
)
var outer = (binding.includeReplace = !!Anot(elem).data(
@ -4072,10 +4105,10 @@
//chrome v37- 下embed标签动态设置的src无法发起请求
if (window.chrome && elem.tagName === 'EMBED') {
var parent = elem.parentNode
var _parent = elem.parentNode
var com = DOC.createComment(':src')
parent.replaceChild(com, elem)
parent.replaceChild(elem, com)
_parent.replaceChild(com, elem)
_parent.replaceChild(elem, com)
}
} else {
var k = i
@ -4390,7 +4423,7 @@
var elem = binding.element
var vmodels = binding.vmodels
binding.changed =
getBindingCallback(elem, 'data-duplex-changed', vmodels) || noop
getBindingCallback(elem, 'data-changed', vmodels) || noop
var params = []
var casting = oneObject('string,number,boolean,checked')
if (elem.type === 'radio' && binding.param === '') {
@ -5010,12 +5043,12 @@
Anot.mix(Anot.effect, {
apply: applyEffect,
append: function(el, parent, after, opts) {
append: function(el, _parent, after, opts) {
return applyEffect(
el,
1,
function() {
parent.appendChild(el)
_parent.appendChild(el)
},
after,
opts
@ -5032,12 +5065,12 @@
opts
)
},
remove: function(el, parent, after, opts) {
remove: function(el, _parent, after, opts) {
return applyEffect(
el,
0,
function() {
if (el.parentNode === parent) parent.removeChild(el)
if (el.parentNode === _parent) _parent.removeChild(el)
},
after,
opts
@ -5050,15 +5083,15 @@
var binding = this
var elem = this.element
var isHtmlFilter = elem.nodeType !== 1
var parent = isHtmlFilter ? elem.parentNode : elem
if (!parent) return
var _parent = isHtmlFilter ? elem.parentNode : elem
if (!_parent) return
val = val == null ? '' : val
if (elem.nodeType === 3) {
var signature = generateID('html')
parent.insertBefore(DOC.createComment(signature), elem)
_parent.insertBefore(DOC.createComment(signature), elem)
binding.element = DOC.createComment(signature + ':end')
parent.replaceChild(binding.element, elem)
_parent.replaceChild(binding.element, elem)
elem = binding.element
}
if (typeof val !== 'object') {
@ -5084,10 +5117,10 @@
if (!node || (node.nodeType === 8 && node.nodeValue === endValue)) {
break
} else {
parent.removeChild(node)
_parent.removeChild(node)
}
}
parent.insertBefore(fragment, elem)
_parent.insertBefore(fragment, elem)
} else {
Anot.clearHTML(elem).appendChild(fragment)
}
@ -5445,14 +5478,9 @@
elem.removeAttribute(binding.name)
effectBinding(elem, binding)
binding.param = binding.param || 'el'
binding.sortedCallback = getBindingCallback(
elem,
'data-repeat-sortby',
binding.vmodels
)
var rendered = getBindingCallback(
elem,
'data-repeat-rendered',
'data-rendered',
binding.vmodels
)
@ -5463,18 +5491,18 @@
binding.start = start
binding.template = anotFragment.cloneNode(false)
var parent = elem.parentNode
parent.replaceChild(end, elem)
parent.insertBefore(start, end)
var _parent = elem.parentNode
_parent.replaceChild(end, elem)
_parent.insertBefore(start, end)
binding.template.appendChild(elem)
binding.element = end
if (rendered) {
var removeFn = Anot.bind(parent, 'datasetchanged', function() {
rendered.apply(parent, parent.args)
Anot.unbind(parent, 'datasetchanged', removeFn)
parent.msRendered = rendered
var removeFn = Anot.bind(_parent, 'datasetchanged', function() {
rendered.apply(_parent, _parent.args)
Anot.unbind(_parent, 'datasetchanged', removeFn)
_parent.msRendered = rendered
})
}
}
@ -5501,14 +5529,6 @@
}
}
var track = this.track
if (binding.sortedCallback) {
//如果有回调,则让它们排序
var keys2 = binding.sortedCallback.call(parent, track)
if (keys2 && Array.isArray(keys2)) {
track = keys2
}
}
var action = 'move'
binding.$repeat = value
var fragments = []
@ -5519,7 +5539,7 @@
var elem = this.element
var length = track.length
var parent = elem.parentNode
var _parent = elem.parentNode
//检查新元素数量
var newCount = 0
@ -5538,7 +5558,7 @@
if (clear) {
while (kill !== start) {
parent.removeChild(kill)
_parent.removeChild(kill)
kill = elem.previousSibling
}
}
@ -5600,7 +5620,7 @@
}
this.proxies = proxies
if (init && !binding.effectDriver) {
parent.insertBefore(transation, elem)
_parent.insertBefore(transation, elem)
fragments.forEach(function(fragment) {
scanNodeArray(fragment.nodes || [], fragment.vmodels)
//if(fragment.vmodels.length > 2)
@ -5632,7 +5652,7 @@
staggerIndex = mayStaggerAnimate(
binding.effectEnterStagger,
function() {
parent.insertBefore(
_parent.insertBefore(
fragment.content,
preElement.nextSibling
)
@ -5652,7 +5672,7 @@
function() {
var curNode = removeItem(proxy2.$anchor)
var inserted = Anot.slice(curNode.childNodes)
parent.insertBefore(curNode, preElement.nextSibling)
_parent.insertBefore(curNode, preElement.nextSibling)
animateRepeat(inserted, 1, binding)
},
staggerIndex
@ -5670,17 +5690,17 @@
//repeat --> duplex
;(function(args) {
parent.args = args
if (parent.msRendered) {
_parent.args = args
if (_parent.msRendered) {
//第一次事件触发,以后直接调用
parent.msRendered.apply(parent, args)
_parent.msRendered.apply(_parent, args)
}
})(kernel.newWatch ? arguments : [action])
var id = setTimeout(function() {
clearTimeout(id)
//触发上层的select回调及自己的rendered回调
Anot.fireDom(parent, 'datasetchanged', {
bubble: parent.msHasEvent
Anot.fireDom(_parent, 'datasetchanged', {
bubble: _parent.msHasEvent
})
})
this.enterCount -= 1

View File

@ -225,15 +225,15 @@ const _Anot = (function() {
if ($elem === DOC.body) {
scanTag($elem, [])
} else {
var $parent = $elem
while (($parent = $parent.parentNode)) {
if ($parent.anotctrl) {
var _parent = $elem
while ((_parent = _parent.parentNode)) {
if (_parent.anotctrl) {
break
}
}
scanTag(
$elem.parentNode,
$parent ? [VMODELS[$parent.anotctrl]] : []
_parent ? [VMODELS[_parent.anotctrl]] : []
)
}
}
@ -1456,6 +1456,7 @@ const _Anot = (function() {
function $emit(key, args) {
var event = this.$events
var _parent = null
if (event && event[key]) {
if (args) {
args[2] = key
@ -1469,22 +1470,22 @@ const _Anot = (function() {
} catch (e) {}
}
}
var parent = this.$up
if (parent) {
_parent = this.$up
if (_parent) {
if (this.$pathname) {
$emit.call(parent, this.$pathname + '.' + key, args) //以确切的值往上冒泡
$emit.call(_parent, this.$pathname + '.' + key, args) //以确切的值往上冒泡
}
$emit.call(parent, '*.' + key, args) //以模糊的值往上冒泡
$emit.call(_parent, '*.' + key, args) //以模糊的值往上冒泡
}
} else {
parent = this.$up
_parent = this.$up
if (this.$ups) {
for (var i in this.$ups) {
$emit.call(this.$ups[i], i + '.' + key, args) //以确切的值往上冒泡
}
return
}
if (parent) {
if (_parent) {
var p = this.$pathname
if (p === '') p = '*'
var path = p + '.' + key
@ -1493,11 +1494,11 @@ const _Anot = (function() {
args = (args && args.concat([path, key])) || [path, key]
if (arr.indexOf('*') === -1) {
$emit.call(parent, path, args) //以确切的值往上冒泡
$emit.call(_parent, path, args) //以确切的值往上冒泡
arr[1] = '*'
$emit.call(parent, arr.join('.'), args) //以模糊的值往上冒泡
$emit.call(_parent, arr.join('.'), args) //以模糊的值往上冒泡
} else {
$emit.call(parent, path, args) //以确切的值往上冒泡
$emit.call(_parent, path, args) //以确切的值往上冒泡
}
}
}
@ -1743,6 +1744,12 @@ const _Anot = (function() {
var v = $vmodel.$children[i]
v.$fire && v.$fire.apply(v, [ee, a])
}
// component! 这是一个特殊的标识,可以直接修改子组件的state值
} else if (path.indexOf('component!') === 0) {
var ee = path.slice(10)
for (var i in $vmodel.$children) {
$vmodel.$children[i][ee] = a
}
} else {
$emit.call($vmodel, path, [a])
}
@ -2758,9 +2765,9 @@ const _Anot = (function() {
}
array.push(obj)
}
var parent = node.parentNode
if (parent && parent.nodeType === 1) {
showHidden(parent, array)
var _parent = node.parentNode
if (_parent && _parent.nodeType === 1) {
showHidden(_parent, array)
}
}
}
@ -3339,12 +3346,16 @@ const _Anot = (function() {
var rnoCollect = /^(:\S+|data-\S+|on[a-z]+|id|style|class)$/
var ronattr = '__fn__'
var specifiedVars = [':disabled', ':loading']
function getOptionsFromTag(elem, vmodels) {
var attributes = elem.attributes
var attributes = aslice.call(elem.attributes, 0)
var ret = {}
for (var i = 0, attr; (attr = attributes[i++]); ) {
var name = attr.name
if (attr.specified && !rnoCollect.test(name)) {
if (
(attr.specified && !rnoCollect.test(name)) ||
specifiedVars.includes(name)
) {
if (name.indexOf(ronattr) === 0) {
name = attr.value.slice(6)
ret[name] = elem[attr.value]
@ -3364,6 +3375,7 @@ const _Anot = (function() {
} else {
ret[camelizeName] = parseData(attr.value)
}
elem.removeAttribute(name)
}
}
}
@ -3739,8 +3751,9 @@ const _Anot = (function() {
arr.forEach(function(elem) {
var slot = elem.getAttribute('slot')
if (slot) {
obj[slot] = obj[slot] || []
elem.removeAttribute('slot')
obj[slot] = elem.outerHTML
obj[slot].push(elem.outerHTML)
}
})
return obj
@ -3771,6 +3784,8 @@ const _Anot = (function() {
//如果还没有解析完,就延迟一下 #1155
return
}
var parentVm = host.vmodels[0]
var state = {}
var props = getOptionsFromTag(elem, host.vmodels)
var $id = props.uuid || generateID(widget)
var __willpush__ = null
@ -3778,7 +3793,24 @@ const _Anot = (function() {
if (props.hasOwnProperty('hostPush')) {
elem.removeAttribute('host-push')
__willpush__ = props.hostPush
props.hostPush = host.vmodels[0][__willpush__]
props.hostPush = parentVm[__willpush__]
}
if (props.hasOwnProperty(':disabled')) {
var disabledKey = props[':disabled']
state.disabled = parentVm[disabledKey]
parentVm.$watch(disabledKey, function(val) {
parentVm.$fire('component!disabled', val)
})
delete props[':disabled']
}
if (props.hasOwnProperty(':loading')) {
var loadingKey = props[':loading']
state.loading = parentVm[loadingKey]
parentVm.$watch(loadingKey, function(val) {
parentVm.$fire('component!loading', val)
})
delete props[':loading']
}
delete props.uuid
@ -3788,6 +3820,7 @@ const _Anot = (function() {
hooks.state = hooks.state || {}
Object.assign(hooks.props, props)
Object.assign(hooks.state, state)
hooks.construct.call(elem, hooks.props, hooks.state)
@ -3810,13 +3843,13 @@ const _Anot = (function() {
var vmodel = Anot(hooks)
delete vmodel.$mounted
host.vmodels[0].$children.push(vmodel)
parentVm.$children.push(vmodel)
elem.msResolved = 1 //防止二进扫描此元素
if (__willpush__) {
hideProperty(vmodel, '$push', function(val) {
host.vmodels[0][__willpush__] = val
parentVm[__willpush__] = val
})
}
@ -3988,12 +4021,12 @@ const _Anot = (function() {
effectBinding(elem, binding)
binding.includeRendered = getBindingCallback(
elem,
'data-include-rendered',
'data-rendered',
binding.vmodels
)
binding.includeLoaded = getBindingCallback(
elem,
'data-include-loaded',
'data-loaded',
binding.vmodels
)
var outer = (binding.includeReplace = !!Anot(elem).data(
@ -4057,10 +4090,10 @@ const _Anot = (function() {
//chrome v37- 下embed标签动态设置的src无法发起请求
if (window.chrome && elem.tagName === 'EMBED') {
var parent = elem.parentNode
var _parent = elem.parentNode
var com = DOC.createComment(':src')
parent.replaceChild(com, elem)
parent.replaceChild(elem, com)
_parent.replaceChild(com, elem)
_parent.replaceChild(elem, com)
}
} else {
var k = i
@ -4375,7 +4408,7 @@ const _Anot = (function() {
var elem = binding.element
var vmodels = binding.vmodels
binding.changed =
getBindingCallback(elem, 'data-duplex-changed', vmodels) || noop
getBindingCallback(elem, 'data-changed', vmodels) || noop
var params = []
var casting = oneObject('string,number,boolean,checked')
if (elem.type === 'radio' && binding.param === '') {
@ -4995,12 +5028,12 @@ const _Anot = (function() {
Anot.mix(Anot.effect, {
apply: applyEffect,
append: function(el, parent, after, opts) {
append: function(el, _parent, after, opts) {
return applyEffect(
el,
1,
function() {
parent.appendChild(el)
_parent.appendChild(el)
},
after,
opts
@ -5017,12 +5050,12 @@ const _Anot = (function() {
opts
)
},
remove: function(el, parent, after, opts) {
remove: function(el, _parent, after, opts) {
return applyEffect(
el,
0,
function() {
if (el.parentNode === parent) parent.removeChild(el)
if (el.parentNode === _parent) _parent.removeChild(el)
},
after,
opts
@ -5035,15 +5068,15 @@ const _Anot = (function() {
var binding = this
var elem = this.element
var isHtmlFilter = elem.nodeType !== 1
var parent = isHtmlFilter ? elem.parentNode : elem
if (!parent) return
var _parent = isHtmlFilter ? elem.parentNode : elem
if (!_parent) return
val = val == null ? '' : val
if (elem.nodeType === 3) {
var signature = generateID('html')
parent.insertBefore(DOC.createComment(signature), elem)
_parent.insertBefore(DOC.createComment(signature), elem)
binding.element = DOC.createComment(signature + ':end')
parent.replaceChild(binding.element, elem)
_parent.replaceChild(binding.element, elem)
elem = binding.element
}
if (typeof val !== 'object') {
@ -5069,10 +5102,10 @@ const _Anot = (function() {
if (!node || (node.nodeType === 8 && node.nodeValue === endValue)) {
break
} else {
parent.removeChild(node)
_parent.removeChild(node)
}
}
parent.insertBefore(fragment, elem)
_parent.insertBefore(fragment, elem)
} else {
Anot.clearHTML(elem).appendChild(fragment)
}
@ -5430,14 +5463,9 @@ const _Anot = (function() {
elem.removeAttribute(binding.name)
effectBinding(elem, binding)
binding.param = binding.param || 'el'
binding.sortedCallback = getBindingCallback(
elem,
'data-repeat-sortby',
binding.vmodels
)
var rendered = getBindingCallback(
elem,
'data-repeat-rendered',
'data-rendered',
binding.vmodels
)
@ -5448,18 +5476,18 @@ const _Anot = (function() {
binding.start = start
binding.template = anotFragment.cloneNode(false)
var parent = elem.parentNode
parent.replaceChild(end, elem)
parent.insertBefore(start, end)
var _parent = elem.parentNode
_parent.replaceChild(end, elem)
_parent.insertBefore(start, end)
binding.template.appendChild(elem)
binding.element = end
if (rendered) {
var removeFn = Anot.bind(parent, 'datasetchanged', function() {
rendered.apply(parent, parent.args)
Anot.unbind(parent, 'datasetchanged', removeFn)
parent.msRendered = rendered
var removeFn = Anot.bind(_parent, 'datasetchanged', function() {
rendered.apply(_parent, _parent.args)
Anot.unbind(_parent, 'datasetchanged', removeFn)
_parent.msRendered = rendered
})
}
}
@ -5486,14 +5514,6 @@ const _Anot = (function() {
}
}
var track = this.track
if (binding.sortedCallback) {
//如果有回调,则让它们排序
var keys2 = binding.sortedCallback.call(parent, track)
if (keys2 && Array.isArray(keys2)) {
track = keys2
}
}
var action = 'move'
binding.$repeat = value
var fragments = []
@ -5504,7 +5524,7 @@ const _Anot = (function() {
var elem = this.element
var length = track.length
var parent = elem.parentNode
var _parent = elem.parentNode
//检查新元素数量
var newCount = 0
@ -5523,7 +5543,7 @@ const _Anot = (function() {
if (clear) {
while (kill !== start) {
parent.removeChild(kill)
_parent.removeChild(kill)
kill = elem.previousSibling
}
}
@ -5585,7 +5605,7 @@ const _Anot = (function() {
}
this.proxies = proxies
if (init && !binding.effectDriver) {
parent.insertBefore(transation, elem)
_parent.insertBefore(transation, elem)
fragments.forEach(function(fragment) {
scanNodeArray(fragment.nodes || [], fragment.vmodels)
//if(fragment.vmodels.length > 2)
@ -5617,7 +5637,7 @@ const _Anot = (function() {
staggerIndex = mayStaggerAnimate(
binding.effectEnterStagger,
function() {
parent.insertBefore(
_parent.insertBefore(
fragment.content,
preElement.nextSibling
)
@ -5637,7 +5657,7 @@ const _Anot = (function() {
function() {
var curNode = removeItem(proxy2.$anchor)
var inserted = Anot.slice(curNode.childNodes)
parent.insertBefore(curNode, preElement.nextSibling)
_parent.insertBefore(curNode, preElement.nextSibling)
animateRepeat(inserted, 1, binding)
},
staggerIndex
@ -5655,17 +5675,17 @@ const _Anot = (function() {
//repeat --> duplex
;(function(args) {
parent.args = args
if (parent.msRendered) {
_parent.args = args
if (_parent.msRendered) {
//第一次事件触发,以后直接调用
parent.msRendered.apply(parent, args)
_parent.msRendered.apply(_parent, args)
}
})(kernel.newWatch ? arguments : [action])
var id = setTimeout(function() {
clearTimeout(id)
//触发上层的select回调及自己的rendered回调
Anot.fireDom(parent, 'datasetchanged', {
bubble: parent.msHasEvent
Anot.fireDom(_parent, 'datasetchanged', {
bubble: _parent.msHasEvent
})
})
this.enterCount -= 1

View File

@ -240,15 +240,15 @@
if ($elem === DOC.body) {
scanTag($elem, [])
} else {
var $parent = $elem
while (($parent = $parent.parentNode)) {
if ($parent.anotctrl) {
var _parent = $elem
while ((_parent = _parent.parentNode)) {
if (_parent.anotctrl) {
break
}
}
scanTag(
$elem.parentNode,
$parent ? [VMODELS[$parent.anotctrl]] : []
_parent ? [VMODELS[_parent.anotctrl]] : []
)
}
}
@ -1471,6 +1471,7 @@
function $emit(key, args) {
var event = this.$events
var _parent = null
if (event && event[key]) {
if (args) {
args[2] = key
@ -1484,22 +1485,22 @@
} catch (e) {}
}
}
var parent = this.$up
if (parent) {
_parent = this.$up
if (_parent) {
if (this.$pathname) {
$emit.call(parent, this.$pathname + '.' + key, args) //以确切的值往上冒泡
$emit.call(_parent, this.$pathname + '.' + key, args) //以确切的值往上冒泡
}
$emit.call(parent, '*.' + key, args) //以模糊的值往上冒泡
$emit.call(_parent, '*.' + key, args) //以模糊的值往上冒泡
}
} else {
parent = this.$up
_parent = this.$up
if (this.$ups) {
for (var i in this.$ups) {
$emit.call(this.$ups[i], i + '.' + key, args) //以确切的值往上冒泡
}
return
}
if (parent) {
if (_parent) {
var p = this.$pathname
if (p === '') p = '*'
var path = p + '.' + key
@ -1508,11 +1509,11 @@
args = (args && args.concat([path, key])) || [path, key]
if (arr.indexOf('*') === -1) {
$emit.call(parent, path, args) //以确切的值往上冒泡
$emit.call(_parent, path, args) //以确切的值往上冒泡
arr[1] = '*'
$emit.call(parent, arr.join('.'), args) //以模糊的值往上冒泡
$emit.call(_parent, arr.join('.'), args) //以模糊的值往上冒泡
} else {
$emit.call(parent, path, args) //以确切的值往上冒泡
$emit.call(_parent, path, args) //以确切的值往上冒泡
}
}
}
@ -1758,6 +1759,12 @@
var v = $vmodel.$children[i]
v.$fire && v.$fire.apply(v, [ee, a])
}
// component! 这是一个特殊的标识,可以直接修改子组件的state值
} else if (path.indexOf('component!') === 0) {
var ee = path.slice(10)
for (var i in $vmodel.$children) {
$vmodel.$children[i][ee] = a
}
} else {
$emit.call($vmodel, path, [a])
}
@ -2773,9 +2780,9 @@
}
array.push(obj)
}
var parent = node.parentNode
if (parent && parent.nodeType === 1) {
showHidden(parent, array)
var _parent = node.parentNode
if (_parent && _parent.nodeType === 1) {
showHidden(_parent, array)
}
}
}
@ -3354,12 +3361,16 @@
var rnoCollect = /^(:\S+|data-\S+|on[a-z]+|id|style|class)$/
var ronattr = '__fn__'
var specifiedVars = [':disabled', ':loading']
function getOptionsFromTag(elem, vmodels) {
var attributes = elem.attributes
var attributes = aslice.call(elem.attributes, 0)
var ret = {}
for (var i = 0, attr; (attr = attributes[i++]); ) {
var name = attr.name
if (attr.specified && !rnoCollect.test(name)) {
if (
(attr.specified && !rnoCollect.test(name)) ||
specifiedVars.includes(name)
) {
if (name.indexOf(ronattr) === 0) {
name = attr.value.slice(6)
ret[name] = elem[attr.value]
@ -3379,6 +3390,7 @@
} else {
ret[camelizeName] = parseData(attr.value)
}
elem.removeAttribute(name)
}
}
}
@ -3754,8 +3766,9 @@
arr.forEach(function(elem) {
var slot = elem.getAttribute('slot')
if (slot) {
obj[slot] = obj[slot] || []
elem.removeAttribute('slot')
obj[slot] = elem.outerHTML
obj[slot].push(elem.outerHTML)
}
})
return obj
@ -3786,6 +3799,8 @@
//如果还没有解析完,就延迟一下 #1155
return
}
var parentVm = host.vmodels[0]
var state = {}
var props = getOptionsFromTag(elem, host.vmodels)
var $id = props.uuid || generateID(widget)
var __willpush__ = null
@ -3793,7 +3808,24 @@
if (props.hasOwnProperty('hostPush')) {
elem.removeAttribute('host-push')
__willpush__ = props.hostPush
props.hostPush = host.vmodels[0][__willpush__]
props.hostPush = parentVm[__willpush__]
}
if (props.hasOwnProperty(':disabled')) {
var disabledKey = props[':disabled']
state.disabled = parentVm[disabledKey]
parentVm.$watch(disabledKey, function(val) {
parentVm.$fire('component!disabled', val)
})
delete props[':disabled']
}
if (props.hasOwnProperty(':loading')) {
var loadingKey = props[':loading']
state.loading = parentVm[loadingKey]
parentVm.$watch(loadingKey, function(val) {
parentVm.$fire('component!loading', val)
})
delete props[':loading']
}
delete props.uuid
@ -3803,6 +3835,7 @@
hooks.state = hooks.state || {}
Object.assign(hooks.props, props)
Object.assign(hooks.state, state)
hooks.construct.call(elem, hooks.props, hooks.state)
@ -3825,13 +3858,13 @@
var vmodel = Anot(hooks)
delete vmodel.$mounted
host.vmodels[0].$children.push(vmodel)
parentVm.$children.push(vmodel)
elem.msResolved = 1 //防止二进扫描此元素
if (__willpush__) {
hideProperty(vmodel, '$push', function(val) {
host.vmodels[0][__willpush__] = val
parentVm[__willpush__] = val
})
}
@ -4003,12 +4036,12 @@
effectBinding(elem, binding)
binding.includeRendered = getBindingCallback(
elem,
'data-include-rendered',
'data-rendered',
binding.vmodels
)
binding.includeLoaded = getBindingCallback(
elem,
'data-include-loaded',
'data-loaded',
binding.vmodels
)
var outer = (binding.includeReplace = !!Anot(elem).data(
@ -4072,10 +4105,10 @@
//chrome v37- 下embed标签动态设置的src无法发起请求
if (window.chrome && elem.tagName === 'EMBED') {
var parent = elem.parentNode
var _parent = elem.parentNode
var com = DOC.createComment(':src')
parent.replaceChild(com, elem)
parent.replaceChild(elem, com)
_parent.replaceChild(com, elem)
_parent.replaceChild(elem, com)
}
} else {
var k = i
@ -4390,7 +4423,7 @@
var elem = binding.element
var vmodels = binding.vmodels
binding.changed =
getBindingCallback(elem, 'data-duplex-changed', vmodels) || noop
getBindingCallback(elem, 'data-changed', vmodels) || noop
var params = []
var casting = oneObject('string,number,boolean,checked')
if (elem.type === 'radio' && binding.param === '') {
@ -5010,12 +5043,12 @@
Anot.mix(Anot.effect, {
apply: applyEffect,
append: function(el, parent, after, opts) {
append: function(el, _parent, after, opts) {
return applyEffect(
el,
1,
function() {
parent.appendChild(el)
_parent.appendChild(el)
},
after,
opts
@ -5032,12 +5065,12 @@
opts
)
},
remove: function(el, parent, after, opts) {
remove: function(el, _parent, after, opts) {
return applyEffect(
el,
0,
function() {
if (el.parentNode === parent) parent.removeChild(el)
if (el.parentNode === _parent) _parent.removeChild(el)
},
after,
opts
@ -5050,15 +5083,15 @@
var binding = this
var elem = this.element
var isHtmlFilter = elem.nodeType !== 1
var parent = isHtmlFilter ? elem.parentNode : elem
if (!parent) return
var _parent = isHtmlFilter ? elem.parentNode : elem
if (!_parent) return
val = val == null ? '' : val
if (elem.nodeType === 3) {
var signature = generateID('html')
parent.insertBefore(DOC.createComment(signature), elem)
_parent.insertBefore(DOC.createComment(signature), elem)
binding.element = DOC.createComment(signature + ':end')
parent.replaceChild(binding.element, elem)
_parent.replaceChild(binding.element, elem)
elem = binding.element
}
if (typeof val !== 'object') {
@ -5084,10 +5117,10 @@
if (!node || (node.nodeType === 8 && node.nodeValue === endValue)) {
break
} else {
parent.removeChild(node)
_parent.removeChild(node)
}
}
parent.insertBefore(fragment, elem)
_parent.insertBefore(fragment, elem)
} else {
Anot.clearHTML(elem).appendChild(fragment)
}
@ -5445,14 +5478,9 @@
elem.removeAttribute(binding.name)
effectBinding(elem, binding)
binding.param = binding.param || 'el'
binding.sortedCallback = getBindingCallback(
elem,
'data-repeat-sortby',
binding.vmodels
)
var rendered = getBindingCallback(
elem,
'data-repeat-rendered',
'data-rendered',
binding.vmodels
)
@ -5463,18 +5491,18 @@
binding.start = start
binding.template = anotFragment.cloneNode(false)
var parent = elem.parentNode
parent.replaceChild(end, elem)
parent.insertBefore(start, end)
var _parent = elem.parentNode
_parent.replaceChild(end, elem)
_parent.insertBefore(start, end)
binding.template.appendChild(elem)
binding.element = end
if (rendered) {
var removeFn = Anot.bind(parent, 'datasetchanged', function() {
rendered.apply(parent, parent.args)
Anot.unbind(parent, 'datasetchanged', removeFn)
parent.msRendered = rendered
var removeFn = Anot.bind(_parent, 'datasetchanged', function() {
rendered.apply(_parent, _parent.args)
Anot.unbind(_parent, 'datasetchanged', removeFn)
_parent.msRendered = rendered
})
}
}
@ -5501,14 +5529,6 @@
}
}
var track = this.track
if (binding.sortedCallback) {
//如果有回调,则让它们排序
var keys2 = binding.sortedCallback.call(parent, track)
if (keys2 && Array.isArray(keys2)) {
track = keys2
}
}
var action = 'move'
binding.$repeat = value
var fragments = []
@ -5519,7 +5539,7 @@
var elem = this.element
var length = track.length
var parent = elem.parentNode
var _parent = elem.parentNode
//检查新元素数量
var newCount = 0
@ -5538,7 +5558,7 @@
if (clear) {
while (kill !== start) {
parent.removeChild(kill)
_parent.removeChild(kill)
kill = elem.previousSibling
}
}
@ -5600,7 +5620,7 @@
}
this.proxies = proxies
if (init && !binding.effectDriver) {
parent.insertBefore(transation, elem)
_parent.insertBefore(transation, elem)
fragments.forEach(function(fragment) {
scanNodeArray(fragment.nodes || [], fragment.vmodels)
//if(fragment.vmodels.length > 2)
@ -5632,7 +5652,7 @@
staggerIndex = mayStaggerAnimate(
binding.effectEnterStagger,
function() {
parent.insertBefore(
_parent.insertBefore(
fragment.content,
preElement.nextSibling
)
@ -5652,7 +5672,7 @@
function() {
var curNode = removeItem(proxy2.$anchor)
var inserted = Anot.slice(curNode.childNodes)
parent.insertBefore(curNode, preElement.nextSibling)
_parent.insertBefore(curNode, preElement.nextSibling)
animateRepeat(inserted, 1, binding)
},
staggerIndex
@ -5670,17 +5690,17 @@
//repeat --> duplex
;(function(args) {
parent.args = args
if (parent.msRendered) {
_parent.args = args
if (_parent.msRendered) {
//第一次事件触发,以后直接调用
parent.msRendered.apply(parent, args)
_parent.msRendered.apply(_parent, args)
}
})(kernel.newWatch ? arguments : [action])
var id = setTimeout(function() {
clearTimeout(id)
//触发上层的select回调及自己的rendered回调
Anot.fireDom(parent, 'datasetchanged', {
bubble: parent.msHasEvent
Anot.fireDom(_parent, 'datasetchanged', {
bubble: _parent.msHasEvent
})
})
this.enterCount -= 1

50
src/js/form/index.js Normal file
View File

@ -0,0 +1,50 @@
/**
* 各种表单元素组件
* @authors yutent (yutent@doui.cc)
* @date 2018-06-12 13:08:41
* @version $Id$
*/
import './style.scss'
const log = console.log
export default Anot.component('button', {
construct(props, state) {
log(props)
state.text = this.textContent
state.style = { 'border-radius': props.radius }
this.classList.add('do-fn-noselect')
this.classList.add('do-button')
this.setAttribute(':click', 'onClick')
},
render() {
let icon = ''
if (this.props.icon) {
icon = `<i class="do-button__icon do-icon-${this.props.icon}"></i>`
}
return `${icon}<span class="do-button__text" :text="text"></span>`
},
state: {
state: '',
disabled: false,
foo: true,
style: {}
},
props: {
click: Anot.PropsTypes.isFunction()
},
skip: ['style'],
componentDidMount() {
Anot(this.$elem).css(this.style)
},
watch: {},
methods: {
onClick() {
// log(this)
if (this.disabled) {
return
}
log('hello world, button')
}
}
})

22
src/js/form/style.scss Normal file
View File

@ -0,0 +1,22 @@
@charset "UTF-8";
/**
*
* @authors yutent (yutent@doui.cc)
* @date 2018-06-12 13:08:26
* @version $Id$
*/
@import "var.scss";
.do-button {overflow:hidden;position:relative;display:inline-block;width:auto;min-width:60px;height:30px;margin-left:5px;padding:0 10px;color:nth($ct, 1);text-align:center;cursor:pointer;
&::before {position:absolute;left:-50%;top:-50%;display:block;width:200%;height:200%;border-radius:50%;background:nth($cp, 2); content:"";opacity:0;transform: scale(0, .0); transition:opacity 1.3s cubic-bezier(0.23, 1, 0.32, 1),transform 1.3s cubic-bezier(0.23, 1, 0.32, 1);}
&:hover {
&::before {opacity:1;transform:scale(1, .8);}
}
&:active {background:nth($cp, 1)}
&__text,&__icon {position:relative;display:inline-block;}
}

View File

@ -7,7 +7,7 @@
'use strict'
//储存版本信息
Anot.ui.router = '0.0.1'
Anot.ui.router = '1.0.0'
//判定A标签的target属性是否指向自身
//thanks https://github.com/quirkey/sammy/blob/master/lib/sammy.js#L219
@ -233,21 +233,13 @@ Anot.component('link', {
delete props.to
},
render() {
return '<a :attr-href="link" :text="props.label" :click="onClick"></a>'
return '<a :attr-href="link" :text="props.label"></a>'
},
state: {
link: ''
},
props: {
label: '',
click: Anot.PropsTypes.isFunction()
},
methods: {
onClick() {
if (typeof this.props.click === 'function') {
this.props.click()
}
}
label: ''
}
})