Skip to content

Commit

Permalink
默认值 #51
Browse files Browse the repository at this point in the history
  • Loading branch information
army8735 committed Sep 8, 2018
1 parent fd08517 commit 91af986
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 2 additions & 0 deletions build/Element.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ var Element = function (_Event) {
props = _ref[2];
children = _ref[3];
}
props = props || [];
children = children || [];
_this.__reset(uid, name, props, children);
return _this;
}
Expand Down
5 changes: 1 addition & 4 deletions build/VirtualDom.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,7 @@ function __findEq(name, child, res, first) {
var VirtualDom = function (_Element) {
_inherits(VirtualDom, _Element);

function VirtualDom(uid, name) {
var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
var children = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];

function VirtualDom(uid, name, props, children) {
_classCallCheck(this, VirtualDom);

// 自闭合标签不能有children
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/Element.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class Element extends Event {
if(Array.isArray(uid)) {
[uid, name, props, children] = [...uid];
}
props = props || [];
children = children || [];
this.__reset(uid, name, props, children);
}
__reset(uid, name, props, children) {
Expand Down
2 changes: 1 addition & 1 deletion src/VirtualDom.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ function __findEq(name, child, res, first) {
}

class VirtualDom extends Element {
constructor(uid, name, props = [], children = []) {
constructor(uid, name, props, children) {
// 自闭合标签不能有children
if(selfClose.hasOwnProperty(name) && children.length) {
throw new Error('self-close tag can not has children: ' + name);
Expand Down
2 changes: 2 additions & 0 deletions web/Element.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ var Element = function (_Event) {
props = _ref[2];
children = _ref[3];
}
props = props || [];
children = children || [];
_this.__reset(uid, name, props, children);
return _this;
}
Expand Down
5 changes: 1 addition & 4 deletions web/VirtualDom.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,7 @@ function __findEq(name, child, res, first) {
var VirtualDom = function (_Element) {
_inherits(VirtualDom, _Element);

function VirtualDom(uid, name) {
var props = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
var children = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];

function VirtualDom(uid, name, props, children) {
_classCallCheck(this, VirtualDom);

// 自闭合标签不能有children
Expand Down

0 comments on commit 91af986

Please sign in to comment.