Skip to content

Commit

Permalink
Merge branch 'dev-owndoc'
Browse files Browse the repository at this point in the history
  • Loading branch information
errorrik committed Dec 6, 2023
2 parents 1d880c6 + f46d0a9 commit 4128a66
Show file tree
Hide file tree
Showing 30 changed files with 699 additions and 132 deletions.
48 changes: 47 additions & 1 deletion doc/anode-pack.md
Original file line number Diff line number Diff line change
Expand Up @@ -1170,4 +1170,50 @@ aPack = [1,"u",1,45,6,1,3,"cmpt"]
"tagName": "u"
}
*/
```
```


### var

- head: 46
- 编码序: `{string}name, {Node}expr`

```js
aPack = [1,"my-ui",1,46,"title",9,,2,3,"Hello ",7,,6,1,3,"name",]
/*
{
"directives": {},
"props": [],
"events": [],
"children": [],
"tagName": "my-ui",
"attrs": [
{
"name": "title",
"expr": {
"type": 7,
"segs": [
{
"type": 1,
"value": "Hello "
},
{
"type": 5,
"expr": {
"type": 4,
"paths": [
{
"type": 1,
"value": "name"
}
]
},
"filters": []
}
]
}
}
]
}
*/
```
32 changes: 16 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@
"karma-sourcemap-loader": "^0.3.7",
"mustache": "^3.0.1",
"opener": "^1.5.1",
"san-anode-cases": "^3.10.1",
"san-html-cases": "^3.13.4",
"san-anode-cases": "^3.14.0",
"san-html-cases": "^3.14.0",
"source-map": "^0.7.3",
"swig-templates": "^2.0.3",
"typescript": "^4.3.5",
Expand Down
24 changes: 0 additions & 24 deletions src/browser/input-event-compatible.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/browser/trigger.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* @param {string} eventName 事件名
*/
function trigger(el, eventName) {
var event = document.createEvent('HTMLEvents');
var event = el.ownerDocument.createEvent('HTMLEvents');
event.initEvent(eventName, true, true);
el.dispatchEvent(event);
}
Expand Down
1 change: 0 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
// require('./util/next-tick');
// require('./browser/ie');
// require('./browser/ie-old-than-9');
// require('./browser/input-event-compatible');
// require('./browser/auto-close-tags');
// require('./util/data-types.js');
// require('./util/create-data-types-checker.js');
Expand Down
20 changes: 17 additions & 3 deletions src/parser/integrate-attr.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,28 @@ function integrateAttr(aNode, name, value, options) {
aNode.vars = [];
}

realName = kebab2camel(realName);
aNode.vars.push({
name: realName,
name: kebab2camel(realName),
expr: parseExpr(value.replace(/(^\{\{|\}\}$)/g, ''))
});
break;

case 'attr':
if (!aNode.attrs) {
aNode.attrs = [];
}

aNode.attrs.push({
name: realName,
expr: value
? parseText(value, options.delimiters)
: boolAttrs[realName]
? {type: ExprType.BOOL, value: true}
: {type: ExprType.STRING, value: ''}
});

break;

default:
if (prefix === 'prop') {
name = realName;
Expand Down Expand Up @@ -167,7 +182,6 @@ function integrateAttr(aNode, name, value, options) {
}
}
}

}

aNode.props.push(
Expand Down
8 changes: 8 additions & 0 deletions src/parser/unpack-anode.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ function unpackANode(packed) {
break;

case 36:
case 46:
node = {
name: packed[++i]
};
Expand Down Expand Up @@ -293,6 +294,11 @@ function unpackANode(packed) {
current.vars.push(node);
break;

case 46:
current.attrs = current.attrs || [];
current.attrs.push(node);
break;

case 37:
current.directives['for'] = node;
break;
Expand Down Expand Up @@ -390,12 +396,14 @@ function unpackANode(packed) {
// Expr: UNARY
// Prop
// var
// attr
// Object Spread Item, Array Item
case 11:
case 2:
case 33:
case 34:
case 36:
case 46:
case 15:
case 17:
case 18:
Expand Down
6 changes: 2 additions & 4 deletions src/view/async-component.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
var guid = require('../util/guid');
var each = require('../util/each');
var insertBefore = require('../browser/insert-before');
var nodeOwnCreateStump = require('./node-own-create-stump');
var nodeOwnSimpleDispose = require('./node-own-simple-dispose');


Expand All @@ -35,7 +34,7 @@ function AsyncComponent(options, loader) {
this.children[0] = new PlaceholderComponent(options);
}

this._create();
this.el = hydrateWalker.doc.createComment(this.id);
insertBefore(this.el, hydrateWalker.target, hydrateWalker.current);

var me = this;
Expand All @@ -47,7 +46,6 @@ function AsyncComponent(options, loader) {
// #[end]
}

AsyncComponent.prototype._create = nodeOwnCreateStump;
AsyncComponent.prototype.dispose = nodeOwnSimpleDispose;

/**
Expand All @@ -64,7 +62,7 @@ AsyncComponent.prototype.attach = function (parentEl, beforeEl) {
component.attach(parentEl, beforeEl);
}

this._create();
this.el = parentEl.ownerDocument.createComment(this.id);
insertBefore(this.el, parentEl, beforeEl);

var me = this;
Expand Down
Loading

0 comments on commit 4128a66

Please sign in to comment.