Skip to content

Commit

Permalink
Merge branch 'v4.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
aui committed Apr 25, 2017
2 parents 1b9d81d + dccaace commit 5aee242
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 deletions.
15 changes: 13 additions & 2 deletions lib/template-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,22 @@ function extend(options) {
var copy = Object.create(this);

for (var name in options) {

var object = void 0;
var value = options[name];
var type = toType(value);

if (type === 'Array' || type === 'Object') {
copy[name] = extend.call(copy[name], value);
if (type === 'Object') {
object = Object.create(copy[name]);
} else if (type === 'Array') {
object = [].concat(copy[name]);
}

if (object) {
for (var index in value) {
object[index] = value[index];
}
copy[name] = object;
} else {
copy[name] = value;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/template-web.js

Large diffs are not rendered by default.

17 changes: 14 additions & 3 deletions src/compile/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,25 @@ const toType = value => {
* @return {Object}
*/
function extend(options) {
const copy = Object.create(this);
let copy = Object.create(this);

for (let name in options) {

let object;
const value = options[name];
const type = toType(value);

if (type === 'Array' || type === 'Object') {
copy[name] = extend.call(copy[name], value);
if (type === 'Object') {
object = Object.create(copy[name]);
} else if (type === 'Array') {
object = [].concat(copy[name]);
}

if (object) {
for (let index in value) {
object[index] = value[index];
}
copy[name] = object;
} else {
copy[name] = value;
}
Expand Down
9 changes: 0 additions & 9 deletions test/compile/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,6 @@ module.exports = {
assert.deepEqual(null, options.rules[0]);
assert.deepEqual(rules[1], options.rules[1]);
assert.deepEqual(length, rules.length);

// const rules = defaults.rules;
// const length = rules.length;
// const options = defaults.$extend({
// rules: []
// });

// assert.deepEqual(0, options.rules.length);
// assert.deepEqual(length, rules.length);
}
}
};

0 comments on commit 5aee242

Please sign in to comment.