omi v1.1.3 - fix dynamic child node problem
This commit is contained in:
parent
a228d34ec8
commit
1dca2d17b5
|
@ -1,5 +1,5 @@
|
|||
/*!
|
||||
* Omi v1.1.2 By dntzhang
|
||||
* Omi v1.1.3 By dntzhang
|
||||
* Github: https://github.com/AlloyTeam/omi
|
||||
* MIT Licensed.
|
||||
*/
|
||||
|
@ -1299,8 +1299,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
this._generateHTMLCSS();
|
||||
if (!isSelf) {
|
||||
this._extractChildren(this);
|
||||
} else if (_omi2['default'].customTags.length > 0) {
|
||||
this.HTML = this._replaceTags(_omi2['default'].customTags, this.HTML);
|
||||
} else {
|
||||
this._extractChildrenString(this);
|
||||
}
|
||||
|
||||
this.children.forEach(function (item) {
|
||||
|
@ -1362,8 +1362,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
this._generateHTMLCSS();
|
||||
if (!isSelf) {
|
||||
this._extractChildren(this);
|
||||
} else if (_omi2['default'].customTags.length > 0) {
|
||||
this.HTML = this._replaceTags(_omi2['default'].customTags, this.HTML);
|
||||
} else {
|
||||
this._extractChildrenString(this);
|
||||
}
|
||||
|
||||
this.children.forEach(function (item) {
|
||||
|
@ -1570,13 +1570,14 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
return current;
|
||||
}
|
||||
}, {
|
||||
key: '_extractChildren',
|
||||
value: function _extractChildren(child) {
|
||||
key: '_extractChildrenString',
|
||||
value: function _extractChildrenString(child) {
|
||||
var _this10 = this;
|
||||
|
||||
if (_omi2['default'].customTags.length > 0) {
|
||||
child.HTML = this._replaceTags(_omi2['default'].customTags, child.HTML);
|
||||
}
|
||||
if (_omi2['default'].customTags.length === 0) return;
|
||||
|
||||
child.HTML = this._replaceTags(_omi2['default'].customTags, child.HTML);
|
||||
|
||||
var arr = child.HTML.match(/<child[^>][\s\S]*?tag=['|"](\S*)['|"][\s\S]*?><\/child>/g);
|
||||
|
||||
if (arr) {
|
||||
|
@ -1586,6 +1587,30 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
var name = attr.tag;
|
||||
delete attr.tag;
|
||||
var cmi = _this10.children[i];
|
||||
if (cmi && cmi.___omi_constructor_name === name) {
|
||||
cmi._omiChildStr = childStr;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: '_extractChildren',
|
||||
value: function _extractChildren(child) {
|
||||
var _this11 = this;
|
||||
|
||||
if (_omi2['default'].customTags.length === 0) return;
|
||||
|
||||
child.HTML = this._replaceTags(_omi2['default'].customTags, child.HTML);
|
||||
|
||||
var arr = child.HTML.match(/<child[^>][\s\S]*?tag=['|"](\S*)['|"][\s\S]*?><\/child>/g);
|
||||
|
||||
if (arr) {
|
||||
arr.forEach(function (childStr, i) {
|
||||
var json = (0, _html2json2['default'])(childStr);
|
||||
var attr = json.child[0].attr;
|
||||
var name = attr.tag;
|
||||
delete attr.tag;
|
||||
var cmi = _this11.children[i];
|
||||
//if not first time to invoke _extractChildren method
|
||||
if (cmi && cmi.___omi_constructor_name === name) {
|
||||
cmi._omiChildStr = childStr;
|
||||
|
@ -1618,15 +1643,15 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
child._omiGroupDataCounter[value] = 0;
|
||||
}
|
||||
groupDataIndex = child._omiGroupDataCounter[value];
|
||||
dataset = _this10._extractPropertyFromString(value, child)[groupDataIndex];
|
||||
dataset = _this11._extractPropertyFromString(value, child)[groupDataIndex];
|
||||
} else if (key.indexOf('data-') === 0) {
|
||||
dataset[_this10._capitalize(key.replace('data-', ''))] = value;
|
||||
dataset[_this11._capitalize(key.replace('data-', ''))] = value;
|
||||
} else if (key.indexOf(':data-') === 0) {
|
||||
dataset[_this10._capitalize(key.replace(':data-', ''))] = eval('(' + value + ')');
|
||||
dataset[_this11._capitalize(key.replace(':data-', ''))] = eval('(' + value + ')');
|
||||
} else if (key === ':data') {
|
||||
dataset = eval('(' + value + ')');
|
||||
} else if (key === 'data') {
|
||||
dataset = _this10._extractPropertyFromString(value, child);
|
||||
dataset = _this11._extractPropertyFromString(value, child);
|
||||
} else if (key === 'preventSelfUpdate' || key === 'psu') {
|
||||
_omi_preventSelfUpdate = true;
|
||||
} else if (key === 'selfDataFirst' || key === 'sdf') {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*!
|
||||
* Omi v1.1.2 By dntzhang
|
||||
* Omi v1.1.3 By dntzhang
|
||||
* Github: https://github.com/AlloyTeam/omi
|
||||
* MIT Licensed.
|
||||
*/
|
||||
|
@ -683,8 +683,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
this._generateHTMLCSS();
|
||||
if (!isSelf) {
|
||||
this._extractChildren(this);
|
||||
} else if (_omi2['default'].customTags.length > 0) {
|
||||
this.HTML = this._replaceTags(_omi2['default'].customTags, this.HTML);
|
||||
} else {
|
||||
this._extractChildrenString(this);
|
||||
}
|
||||
|
||||
this.children.forEach(function (item) {
|
||||
|
@ -746,8 +746,8 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
this._generateHTMLCSS();
|
||||
if (!isSelf) {
|
||||
this._extractChildren(this);
|
||||
} else if (_omi2['default'].customTags.length > 0) {
|
||||
this.HTML = this._replaceTags(_omi2['default'].customTags, this.HTML);
|
||||
} else {
|
||||
this._extractChildrenString(this);
|
||||
}
|
||||
|
||||
this.children.forEach(function (item) {
|
||||
|
@ -954,13 +954,14 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
return current;
|
||||
}
|
||||
}, {
|
||||
key: '_extractChildren',
|
||||
value: function _extractChildren(child) {
|
||||
key: '_extractChildrenString',
|
||||
value: function _extractChildrenString(child) {
|
||||
var _this10 = this;
|
||||
|
||||
if (_omi2['default'].customTags.length > 0) {
|
||||
child.HTML = this._replaceTags(_omi2['default'].customTags, child.HTML);
|
||||
}
|
||||
if (_omi2['default'].customTags.length === 0) return;
|
||||
|
||||
child.HTML = this._replaceTags(_omi2['default'].customTags, child.HTML);
|
||||
|
||||
var arr = child.HTML.match(/<child[^>][\s\S]*?tag=['|"](\S*)['|"][\s\S]*?><\/child>/g);
|
||||
|
||||
if (arr) {
|
||||
|
@ -970,6 +971,30 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
var name = attr.tag;
|
||||
delete attr.tag;
|
||||
var cmi = _this10.children[i];
|
||||
if (cmi && cmi.___omi_constructor_name === name) {
|
||||
cmi._omiChildStr = childStr;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: '_extractChildren',
|
||||
value: function _extractChildren(child) {
|
||||
var _this11 = this;
|
||||
|
||||
if (_omi2['default'].customTags.length === 0) return;
|
||||
|
||||
child.HTML = this._replaceTags(_omi2['default'].customTags, child.HTML);
|
||||
|
||||
var arr = child.HTML.match(/<child[^>][\s\S]*?tag=['|"](\S*)['|"][\s\S]*?><\/child>/g);
|
||||
|
||||
if (arr) {
|
||||
arr.forEach(function (childStr, i) {
|
||||
var json = (0, _html2json2['default'])(childStr);
|
||||
var attr = json.child[0].attr;
|
||||
var name = attr.tag;
|
||||
delete attr.tag;
|
||||
var cmi = _this11.children[i];
|
||||
//if not first time to invoke _extractChildren method
|
||||
if (cmi && cmi.___omi_constructor_name === name) {
|
||||
cmi._omiChildStr = childStr;
|
||||
|
@ -1002,15 +1027,15 @@ return /******/ (function(modules) { // webpackBootstrap
|
|||
child._omiGroupDataCounter[value] = 0;
|
||||
}
|
||||
groupDataIndex = child._omiGroupDataCounter[value];
|
||||
dataset = _this10._extractPropertyFromString(value, child)[groupDataIndex];
|
||||
dataset = _this11._extractPropertyFromString(value, child)[groupDataIndex];
|
||||
} else if (key.indexOf('data-') === 0) {
|
||||
dataset[_this10._capitalize(key.replace('data-', ''))] = value;
|
||||
dataset[_this11._capitalize(key.replace('data-', ''))] = value;
|
||||
} else if (key.indexOf(':data-') === 0) {
|
||||
dataset[_this10._capitalize(key.replace(':data-', ''))] = eval('(' + value + ')');
|
||||
dataset[_this11._capitalize(key.replace(':data-', ''))] = eval('(' + value + ')');
|
||||
} else if (key === ':data') {
|
||||
dataset = eval('(' + value + ')');
|
||||
} else if (key === 'data') {
|
||||
dataset = _this10._extractPropertyFromString(value, child);
|
||||
dataset = _this11._extractPropertyFromString(value, child);
|
||||
} else if (key === 'preventSelfUpdate' || key === 'psu') {
|
||||
_omi_preventSelfUpdate = true;
|
||||
} else if (key === 'selfDataFirst' || key === 'sdf') {
|
||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
|
@ -1,10 +0,0 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Omi</title>
|
||||
</head>
|
||||
<body>
|
||||
<script src="bundler.js"></script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,39 +0,0 @@
|
|||
import Omi from '../../../src/index.js';
|
||||
|
||||
import SubHello from './sub_hello.js';
|
||||
import World from './world.js';
|
||||
|
||||
class Hello extends Omi.Component {
|
||||
constructor(data) {
|
||||
super(data);
|
||||
|
||||
}
|
||||
style () {
|
||||
return `
|
||||
h1{
|
||||
cursor:pointer;
|
||||
}
|
||||
`;
|
||||
}
|
||||
handleClick(dom){
|
||||
alert(dom.innerHTML);
|
||||
}
|
||||
render() {
|
||||
return `
|
||||
<div>
|
||||
<h1 onclick="handleClick(this)">Omi</h1>
|
||||
<World omi-id="world" data-name="abcd" data-list='{"name":"Latch", "album":"Disclosure", "date":"2013"}' />
|
||||
<div class="test">
|
||||
Hello {{name}}!
|
||||
<SubHello name="list" />
|
||||
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Omi.makeHTML('Hello', Hello);
|
||||
|
||||
export default Hello;
|
|
@ -1,28 +0,0 @@
|
|||
import Omi from '../../../src/index.js';
|
||||
import SubSubHello from './sub_sub_hello.js';
|
||||
|
||||
class SubHello extends Omi.Component {
|
||||
constructor(data) {
|
||||
super(data);
|
||||
}
|
||||
style(){
|
||||
return`
|
||||
a{
|
||||
color: #4078c0;
|
||||
text-decoration: none;
|
||||
}
|
||||
`;
|
||||
}
|
||||
render() {
|
||||
return `
|
||||
<div>
|
||||
<a href="https://github.com/AlloyTeam/AlloyTouch/wiki/Scoped-CSS">link</a>
|
||||
i am SubHello's instance2{{name}}!
|
||||
<SubSubHello />
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
Omi.makeHTML('SubHello', SubHello);
|
||||
|
||||
export default SubHello;
|
|
@ -1,18 +0,0 @@
|
|||
import Omi from '../../../src/index.js';
|
||||
|
||||
class SubSubHello extends Omi.Component {
|
||||
constructor(data) {
|
||||
super(data);
|
||||
}
|
||||
render() {
|
||||
return `
|
||||
<div>
|
||||
i am SubSubHello's instance{{name}}!
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
Omi.makeHTML('SubSubHello', SubSubHello);
|
||||
|
||||
export default SubSubHello;
|
|
@ -1,18 +0,0 @@
|
|||
import Omi from '../../../src/index.js';
|
||||
|
||||
class World extends Omi.Component {
|
||||
constructor(data) {
|
||||
super(data);
|
||||
}
|
||||
render() {
|
||||
return `
|
||||
<div>
|
||||
i am World's instance2{{list}}!
|
||||
</div>`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Omi.makeHTML('World', World);
|
||||
|
||||
export default World;
|
|
@ -1,23 +0,0 @@
|
|||
import Hello from './js/hello.js';
|
||||
|
||||
import World from './js/world.js';
|
||||
|
||||
let hello = new Hello({ name:'Omi'});
|
||||
|
||||
Omi.render(hello,'body');
|
||||
|
||||
let world = new World({name:"abcd",list:'{"name":"Latch", "album":"Disclosure", "date":"2013"}'});
|
||||
hello.addComponent("afterEnd",".test",world);
|
||||
|
||||
setTimeout(function(){
|
||||
Omi.mapping["world"].data.list ="aa"
|
||||
Omi.mapping["world"].update();
|
||||
},1000);
|
||||
|
||||
setTimeout(function(){
|
||||
hello.removeComponent(world);
|
||||
},2000);
|
||||
|
||||
setTimeout(function(){
|
||||
hello.addComponent("afterEnd",".test",world);
|
||||
},3000);
|
|
@ -1395,8 +1395,8 @@
|
|||
this._generateHTMLCSS();
|
||||
if (!isSelf) {
|
||||
this._extractChildren(this);
|
||||
} else if (_omi2['default'].customTags.length > 0) {
|
||||
this.HTML = this._replaceTags(_omi2['default'].customTags, this.HTML);
|
||||
} else {
|
||||
this._extractChildrenString(this);
|
||||
}
|
||||
|
||||
this.children.forEach(function (item) {
|
||||
|
@ -1458,8 +1458,8 @@
|
|||
this._generateHTMLCSS();
|
||||
if (!isSelf) {
|
||||
this._extractChildren(this);
|
||||
} else if (_omi2['default'].customTags.length > 0) {
|
||||
this.HTML = this._replaceTags(_omi2['default'].customTags, this.HTML);
|
||||
} else {
|
||||
this._extractChildrenString(this);
|
||||
}
|
||||
|
||||
this.children.forEach(function (item) {
|
||||
|
@ -1643,11 +1643,7 @@
|
|||
}
|
||||
});
|
||||
|
||||
Object.keys(baseData).forEach(function (key) {
|
||||
_this9._dataset[key] = attr[key];
|
||||
});
|
||||
|
||||
return this._dataset;
|
||||
return Object.assign(baseData, this._dataset);
|
||||
}
|
||||
}, {
|
||||
key: '_capitalize',
|
||||
|
@ -1670,13 +1666,14 @@
|
|||
return current;
|
||||
}
|
||||
}, {
|
||||
key: '_extractChildren',
|
||||
value: function _extractChildren(child) {
|
||||
key: '_extractChildrenString',
|
||||
value: function _extractChildrenString(child) {
|
||||
var _this10 = this;
|
||||
|
||||
if (_omi2['default'].customTags.length > 0) {
|
||||
child.HTML = this._replaceTags(_omi2['default'].customTags, child.HTML);
|
||||
}
|
||||
if (_omi2['default'].customTags.length === 0) return;
|
||||
|
||||
child.HTML = this._replaceTags(_omi2['default'].customTags, child.HTML);
|
||||
|
||||
var arr = child.HTML.match(/<child[^>][\s\S]*?tag=['|"](\S*)['|"][\s\S]*?><\/child>/g);
|
||||
|
||||
if (arr) {
|
||||
|
@ -1686,6 +1683,30 @@
|
|||
var name = attr.tag;
|
||||
delete attr.tag;
|
||||
var cmi = _this10.children[i];
|
||||
if (cmi && cmi.___omi_constructor_name === name) {
|
||||
cmi._omiChildStr = childStr;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: '_extractChildren',
|
||||
value: function _extractChildren(child) {
|
||||
var _this11 = this;
|
||||
|
||||
if (_omi2['default'].customTags.length === 0) return;
|
||||
|
||||
child.HTML = this._replaceTags(_omi2['default'].customTags, child.HTML);
|
||||
|
||||
var arr = child.HTML.match(/<child[^>][\s\S]*?tag=['|"](\S*)['|"][\s\S]*?><\/child>/g);
|
||||
|
||||
if (arr) {
|
||||
arr.forEach(function (childStr, i) {
|
||||
var json = (0, _html2json2['default'])(childStr);
|
||||
var attr = json.child[0].attr;
|
||||
var name = attr.tag;
|
||||
delete attr.tag;
|
||||
var cmi = _this11.children[i];
|
||||
//if not first time to invoke _extractChildren method
|
||||
if (cmi && cmi.___omi_constructor_name === name) {
|
||||
cmi._omiChildStr = childStr;
|
||||
|
@ -1718,15 +1739,15 @@
|
|||
child._omiGroupDataCounter[value] = 0;
|
||||
}
|
||||
groupDataIndex = child._omiGroupDataCounter[value];
|
||||
dataset = _this10._extractPropertyFromString(value, child)[groupDataIndex];
|
||||
dataset = _this11._extractPropertyFromString(value, child)[groupDataIndex];
|
||||
} else if (key.indexOf('data-') === 0) {
|
||||
dataset[_this10._capitalize(key.replace('data-', ''))] = value;
|
||||
dataset[_this11._capitalize(key.replace('data-', ''))] = value;
|
||||
} else if (key.indexOf(':data-') === 0) {
|
||||
dataset[_this10._capitalize(key.replace(':data-', ''))] = eval('(' + value + ')');
|
||||
dataset[_this11._capitalize(key.replace(':data-', ''))] = eval('(' + value + ')');
|
||||
} else if (key === ':data') {
|
||||
dataset = eval('(' + value + ')');
|
||||
} else if (key === 'data') {
|
||||
dataset = _this10._extractPropertyFromString(value, child);
|
||||
dataset = _this11._extractPropertyFromString(value, child);
|
||||
} else if (key === 'preventSelfUpdate' || key === 'psu') {
|
||||
_omi_preventSelfUpdate = true;
|
||||
} else if (key === 'selfDataFirst' || key === 'sdf') {
|
||||
|
@ -2970,7 +2991,7 @@
|
|||
_createClass(List, [{
|
||||
key: 'render',
|
||||
value: function render() {
|
||||
return ' <div>\n <Test data-name="abc"/>\n <ul> {{#items}} <li>{{.}}</li> {{/items}}</ul>\n </div>';
|
||||
return ' <div>\n <Test data-name="' + Math.random() + '"/>\n <ul> {{#items}} <li>{{.}}</li> {{/items}}</ul>\n </div>';
|
||||
}
|
||||
}]);
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ class List extends Omi.Component {
|
|||
|
||||
render () {
|
||||
return ` <div>
|
||||
<Test data-name="abc"/>
|
||||
<Test data-name="${Math.random()}"/>
|
||||
<ul> {{#items}} <li>{{.}}</li> {{/items}}</ul>
|
||||
</div>`
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "omi",
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.3",
|
||||
"description": "Open and modern framework for building user interfaces.",
|
||||
"main": "dist/omi.js",
|
||||
"scripts": {
|
||||
|
|
|
@ -210,8 +210,8 @@ class Component {
|
|||
this._generateHTMLCSS()
|
||||
if(!isSelf) {
|
||||
this._extractChildren(this)
|
||||
}else if (Omi.customTags.length > 0) {
|
||||
this.HTML = this._replaceTags(Omi.customTags, this.HTML)
|
||||
}else {
|
||||
this._extractChildrenString(this)
|
||||
}
|
||||
|
||||
this.children.forEach(item => {
|
||||
|
@ -269,8 +269,8 @@ class Component {
|
|||
this._generateHTMLCSS()
|
||||
if (!isSelf) {
|
||||
this._extractChildren(this)
|
||||
} else if (Omi.customTags.length > 0) {
|
||||
this.HTML = this._replaceTags(Omi.customTags, this.HTML)
|
||||
} else {
|
||||
this._extractChildrenString(this)
|
||||
}
|
||||
|
||||
this.children.forEach(item => {
|
||||
|
@ -457,10 +457,32 @@ class Component {
|
|||
|
||||
}
|
||||
|
||||
_extractChildren(child){
|
||||
if (Omi.customTags.length > 0) {
|
||||
child.HTML = this._replaceTags(Omi.customTags, child.HTML)
|
||||
_extractChildrenString(child){
|
||||
if (Omi.customTags.length === 0) return
|
||||
|
||||
child.HTML = this._replaceTags(Omi.customTags, child.HTML)
|
||||
|
||||
let arr = child.HTML.match(/<child[^>][\s\S]*?tag=['|"](\S*)['|"][\s\S]*?><\/child>/g)
|
||||
|
||||
if(arr){
|
||||
arr.forEach( (childStr, i) =>{
|
||||
let json = html2json(childStr)
|
||||
let attr = json.child[0].attr
|
||||
let name = attr.tag
|
||||
delete attr.tag
|
||||
let cmi = this.children[i]
|
||||
if (cmi && cmi.___omi_constructor_name === name) {
|
||||
cmi._omiChildStr = childStr
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
_extractChildren(child){
|
||||
if (Omi.customTags.length === 0) return
|
||||
|
||||
child.HTML = this._replaceTags(Omi.customTags, child.HTML)
|
||||
|
||||
let arr = child.HTML.match(/<child[^>][\s\S]*?tag=['|"](\S*)['|"][\s\S]*?><\/child>/g)
|
||||
|
||||
if(arr){
|
||||
|
|
Loading…
Reference in New Issue