Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/blaze-hot/update-templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ let overrideTemplateElseBlock = null;

const oldConstructView = Template.prototype.constructView;

Template.prototype.constructView = function () {
let view = oldConstructView.apply(this, arguments);
Template.prototype.constructView = function (...args) {
let view = oldConstructView.apply(this, args);
let templateName = this.viewName;

view.onViewCreated(function () {
Expand Down
8 changes: 4 additions & 4 deletions packages/blaze/attrs.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ AttributeHandler.prototype.update = function (element, oldValue, value) {

AttributeHandler.extend = function (options) {
const curType = this;
const subType = function AttributeHandlerSubtype(/*arguments*/) {
AttributeHandler.apply(this, arguments);
const subType = function AttributeHandlerSubtype(...args) {
AttributeHandler.apply(this, args);
};
subType.prototype = new curType;
subType.extend = curType.extend;
Expand Down Expand Up @@ -289,9 +289,9 @@ const getUrlProtocol = function (url) {
// out the 'protocol' property of the attribute.
const origUpdate = AttributeHandler.prototype.update;
const UrlHandler = AttributeHandler.extend({
update: function (element, oldValue, value) {
update: function (...args) {
const [element, oldValue, value] = args;
const self = this;
const args = arguments;

if (Blaze._javascriptUrlsAllowed()) {
origUpdate.apply(self, args);
Expand Down
5 changes: 3 additions & 2 deletions packages/blaze/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,12 @@ const HandlerRec = function (elem, type, selector, handler, recipient) {
// It's also important that the closure have access to
// `this` when it is not called with it set.
this.delegatedHandler = (function (h) {
return function (evt) {
return function (...args) {
const [evt] = args;
if ((! h.selector) && evt.currentTarget !== evt.target)
// no selector means only fire on target
return;
return h.handler.apply(h.recipient, arguments);
return h.handler.apply(h.recipient, args);
};
})(this);

Expand Down
4 changes: 2 additions & 2 deletions packages/blaze/exceptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ Blaze._wrapCatchingExceptions = function (f, where) {
if (typeof f !== 'function')
return f;

return function (...arguments) {
return function (...args) {
try {
return f.apply(this, arguments);
return f.apply(this, args);
} catch (e) {
Blaze._reportException(e, 'Exception in ' + where + ':');
}
Expand Down
9 changes: 4 additions & 5 deletions packages/blaze/preamble.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,13 @@ const nativeBind = Function.prototype.bind;
// An implementation of _.bind which allows better optimization.
// See: https://github.com/petkaantonov/bluebird/wiki/Optimization-killers#3-managing-arguments
if (nativeBind) {
Blaze._bind = function (func, obj, ...rest) {
if (arguments.length === 2) {
Blaze._bind = function (...args) {
const [func, obj, ...rest] = args
if (args.length === 2) {
return nativeBind.call(func, obj);
}

const args = [obj, ...rest];

return nativeBind.apply(func, args);
return nativeBind.apply(func, [obj, ...rest]);
};
}
else {
Expand Down
4 changes: 2 additions & 2 deletions packages/blaze/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,9 +527,9 @@ Template.prototype.events = function (eventMap) {
let eventMap2 = {};
for (let k in eventMap) {
eventMap2[k] = (function (k, v) {
return function (event /*, ...*/) {
return function (...args) {
const view = this; // passed by EventAugmenter
const args = Array.prototype.slice.call(arguments);
const [event] = args;
// Exiting the current computation to avoid creating unnecessary
// and unexpected reactive dependencies with Templates data
// or any other reactive dependencies defined in event handlers
Expand Down
5 changes: 3 additions & 2 deletions packages/blaze/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -911,11 +911,12 @@ Blaze._addEventMap = function (view, eventMap, thisInHandler) {
const selector = parts.join(' ');
handles.push(Blaze._EventSupport.listen(
element, newEvents, selector,
function (evt) {
function (...args) {
const [evt] = args
if (! range.containsElement(evt.currentTarget, selector, newEvents))
return null;
const handlerThis = thisInHandler || this;
const handlerArgs = arguments;
const handlerArgs = args;
return Blaze._withCurrentView(view, function () {
return handler.apply(handlerThis, handlerArgs);
});
Expand Down
30 changes: 16 additions & 14 deletions packages/htmljs/visitors.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ Visitor.def = function (options) {

Visitor.extend = function (options) {
var curType = this;
var subType = function HTMLVisitorSubtype(/*arguments*/) {
Visitor.apply(this, arguments);
var subType = function HTMLVisitorSubtype(...args) {
Visitor.apply(this, args);
};
subType.prototype = new curType;
subType.extend = curType.extend;
Expand All @@ -48,39 +48,40 @@ Visitor.extend = function (options) {
};

Visitor.def({
visit: function (content/*, ...*/) {
visit: function (...args) {
const [content] = args;
if (content == null)
// null or undefined.
return this.visitNull.apply(this, arguments);
return this.visitNull.apply(this, args);

if (typeof content === 'object') {
if (content.htmljsType) {
switch (content.htmljsType) {
case Tag.htmljsType:
return this.visitTag.apply(this, arguments);
return this.visitTag.apply(this, args);
case CharRef.htmljsType:
return this.visitCharRef.apply(this, arguments);
return this.visitCharRef.apply(this, args);
case Comment.htmljsType:
return this.visitComment.apply(this, arguments);
return this.visitComment.apply(this, args);
case Raw.htmljsType:
return this.visitRaw.apply(this, arguments);
return this.visitRaw.apply(this, args);
default:
throw new Error("Unknown htmljs type: " + content.htmljsType);
}
}

if (isArray(content))
return this.visitArray.apply(this, arguments);
return this.visitArray.apply(this, args);

return this.visitObject.apply(this, arguments);
return this.visitObject.apply(this, args);

} else if ((typeof content === 'string') ||
(typeof content === 'boolean') ||
(typeof content === 'number')) {
return this.visitPrimitive.apply(this, arguments);
return this.visitPrimitive.apply(this, args);

} else if (typeof content === 'function') {
return this.visitFunction.apply(this, arguments);
return this.visitFunction.apply(this, args);
}

throw new Error("Unexpected object in htmljs: " + content);
Expand Down Expand Up @@ -156,7 +157,8 @@ TransformingVisitor.def({
// Transform the `.attrs` property of a tag, which may be a dictionary,
// an array, or in some uses, a foreign object (such as
// a template tag).
visitAttributes: function (attrs, ...args) {
visitAttributes: function (...all) {
const [attrs, ...args] = all;
// Allow Promise-like values here; these will be handled in materializer.
if (isPromiseLike(attrs)) {
return attrs;
Expand Down Expand Up @@ -187,7 +189,7 @@ TransformingVisitor.def({
var newAttrs = oldAttrs;
if (oldAttrs) {
var attrArgs = [null, null];
attrArgs.push.apply(attrArgs, arguments);
attrArgs.push.apply(attrArgs, all);
for (var k in oldAttrs) {
var oldValue = oldAttrs[k];
attrArgs[0] = k;
Expand Down
4 changes: 2 additions & 2 deletions packages/observe-sequence/observe_sequence.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ const has = (obj, path) => {
return !!length;
};

const warn = function () {
const warn = function (...args) {
if (ObserveSequence._suppressWarnings) {
ObserveSequence._suppressWarnings--;
} else {
if (typeof console !== 'undefined' && console.warn)
console.warn.apply(console, arguments);
console.warn.apply(console, args);

ObserveSequence._loggedWarnings++;
}
Expand Down
7 changes: 3 additions & 4 deletions packages/observe-sequence/observe_sequence_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,9 @@ const extend = function(child, parent) {
const ArraySubclass = (function (superClass) {
extend(ArraySubclass, superClass);

function ArraySubclass() {
if (arguments.length > 0) {
const items = this.slice.call(arguments, 0);
this.splice.apply(this, [0, 0].concat(this.slice.call(items)));
function ArraySubclass(...items) {
if (items.length > 0) {
this.splice.apply(this, [0, 0].concat(items.slice()));
}
}

Expand Down
5 changes: 3 additions & 2 deletions packages/spacebars-compiler/optimizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,14 @@ export function toRaw(x) {

export const TreeTransformer = HTML.TransformingVisitor.extend();
TreeTransformer.def({
visitAttributes: function (attrs/*, ...*/) {
visitAttributes: function (...args) {
const [attrs] = args;
// pass template tags through by default
if (attrs instanceof HTMLTools.TemplateTag)
return attrs;

return HTML.TransformingVisitor.prototype.visitAttributes.apply(
this, arguments);
this, args);
}
});

Expand Down
4 changes: 2 additions & 2 deletions packages/spacebars-compiler/templatetag.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ import { BlazeTools } from 'meteor/blaze-tools';

var TEMPLATE_TAG_POSITION = HTMLTools.TEMPLATE_TAG_POSITION;

export function TemplateTag () {
HTMLTools.TemplateTag.apply(this, arguments);
export function TemplateTag (...args) {
HTMLTools.TemplateTag.apply(this, args);
}

TemplateTag.prototype = new HTMLTools.TemplateTag;
Expand Down
8 changes: 4 additions & 4 deletions packages/spacebars-tests/old_templates_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,8 @@ var extendTemplateWithInit = function (template, initFunc) {
template.viewName + '-extended',
template.renderFunction
);
tmpl.constructView = function (/*args*/) {
var view = Template.prototype.constructView.apply(this, arguments);
tmpl.constructView = function (...args) {
var view = Template.prototype.constructView.apply(this, args);
initFunc(view);
return view;
};
Expand Down Expand Up @@ -2163,11 +2163,11 @@ Tinytest.add(
var args = ['param1', 'param2', { option: 1 }, 1, 2, 3];

tmpl.events({
someCustomEvent: function (event, template) {
someCustomEvent: function (...args1) {
var i;
for (i = 0; i < args.length; i++) {
// expect the arguments to be just after template
test.equal(arguments[i + 2], args[i]);
test.equal(args1[i + 2], args[i]);
}
captured = true;
},
Expand Down
14 changes: 7 additions & 7 deletions packages/spacebars-tests/template_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ var extendTemplateWithInit = function (template, initFunc) {
template.viewName + '-extended',
template.renderFunction
);
tmpl.constructView = function (/*args*/) {
var view = Template.prototype.constructView.apply(this, arguments);
tmpl.constructView = function (...args) {
var view = Template.prototype.constructView.apply(this, args);
initFunc(view);
return view;
};
Expand Down Expand Up @@ -143,13 +143,13 @@ Tinytest.add(

// One more test, similar to the above, but where `user` is not null but
// `user.prefixName` is. This test was also broken prior to the fix.
var tmpl4 = copyTemplate(baseTmpl);
tmpl4.helpers({
var tmpl5 = copyTemplate(baseTmpl);
tmpl5.helpers({
user: function () {
return { prefixName: null };
},
});
div = renderToDiv(tmpl4);
div = renderToDiv(tmpl5);
test.equal(canonicalizeHtml(div.innerHTML), '');
}
);
Expand Down Expand Up @@ -2576,11 +2576,11 @@ Tinytest.add(
var args = ['param1', 'param2', { option: 1 }, 1, 2, 3];

tmpl.events({
someCustomEvent: function (event, template) {
someCustomEvent: function (...args1) {
var i;
for (i = 0; i < args.length; i++) {
// expect the arguments to be just after template
test.equal(arguments[i + 2], args[i]);
test.equal(args1[i + 2], args[i]);
}
captured = true;
},
Expand Down
4 changes: 2 additions & 2 deletions packages/spacebars-tests/templating_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -606,11 +606,11 @@ Tinytest.add("spacebars-tests - templating_tests - events", function (test) {

Tinytest.add('spacebars-tests - templating_tests - helper typecast Issue #617', function (test) {

Template.registerHelper('testTypeCasting', function (/*arguments*/) {
Template.registerHelper('testTypeCasting', function (...args) {
// Return a string representing the arguments passed to this
// function, including types. eg:
// (1, true) -> "[number,1][boolean,true]"
return Array.from(arguments).reduce(function (memo, arg) {
return Array.from(args).reduce(function (memo, arg) {
if (typeof arg === 'object')
return memo + "[object]";
return memo + "[" + typeof arg + "," + arg + "]";
Expand Down
Loading