From 2adfe2e81d107d6823478ed92f7a8cc5b2a72398 Mon Sep 17 00:00:00 2001 From: Emmanuel Antico Date: Sun, 30 Jul 2017 15:40:54 -0300 Subject: [PATCH] fix: trasnsform arguments to array before override --- lib/macros.js | 2 +- test/templates/output/require_with_args.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/macros.js b/lib/macros.js index babf95f..b49a4b2 100644 --- a/lib/macros.js +++ b/lib/macros.js @@ -11,7 +11,7 @@ var strRepeat = function (str, times) { }; // Used to translate require macros to override arguments -var objExtend = function (args, obj) {var _a = args.slice(1); _a.unshift(Object.assign(obj, args[0])); return _a;}; +var objExtend = function (args, obj) {args = Array.prototype.slice.call(args);var _a = args.slice(1); _a.unshift(Object.assign(obj, args[0])); return _a;}; // Default macros module.exports = { diff --git a/test/templates/output/require_with_args.txt b/test/templates/output/require_with_args.txt index 5a87d3e..df808e2 100644 --- a/test/templates/output/require_with_args.txt +++ b/test/templates/output/require_with_args.txt @@ -1,7 +1,7 @@ module.exports = function(obj){ var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');}; with(obj||{}){ -__p+='Hello, ' + require("./bar.html").apply(null,(function (args, obj) {var _a = args.slice(1); _a.unshift(Object.assign(obj, args[0])); return _a;})(arguments, {"name":"emma","role":"dev"})) + '\n'; +__p+='Hello, ' + require("./bar.html").apply(null,(function (args, obj) {args = Array.prototype.slice.call(args);var _a = args.slice(1); _a.unshift(Object.assign(obj, args[0])); return _a;})(arguments, {"name":"emma","role":"dev"})) + '\n'; } return __p; };