vendor/assets/javascripts/handlebars.js in handlebars_assets-0.23.7 vs vendor/assets/javascripts/handlebars.js in handlebars_assets-0.23.8
- old
+ new
@@ -1,11 +1,11 @@
/**!
@license
- handlebars v4.5.3
+ handlebars v4.7.3
-Copyright (C) 2011-2017 by Yehuda Katz
+Copyright (C) 2011-2019 by Yehuda Katz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
@@ -90,27 +90,27 @@
var _handlebarsRuntime2 = _interopRequireDefault(_handlebarsRuntime);
// Compiler imports
- var _handlebarsCompilerAst = __webpack_require__(40);
+ var _handlebarsCompilerAst = __webpack_require__(45);
var _handlebarsCompilerAst2 = _interopRequireDefault(_handlebarsCompilerAst);
- var _handlebarsCompilerBase = __webpack_require__(41);
+ var _handlebarsCompilerBase = __webpack_require__(46);
- var _handlebarsCompilerCompiler = __webpack_require__(46);
+ var _handlebarsCompilerCompiler = __webpack_require__(51);
- var _handlebarsCompilerJavascriptCompiler = __webpack_require__(49);
+ var _handlebarsCompilerJavascriptCompiler = __webpack_require__(52);
var _handlebarsCompilerJavascriptCompiler2 = _interopRequireDefault(_handlebarsCompilerJavascriptCompiler);
- var _handlebarsCompilerVisitor = __webpack_require__(44);
+ var _handlebarsCompilerVisitor = __webpack_require__(49);
var _handlebarsCompilerVisitor2 = _interopRequireDefault(_handlebarsCompilerVisitor);
- var _handlebarsNoConflict = __webpack_require__(39);
+ var _handlebarsNoConflict = __webpack_require__(44);
var _handlebarsNoConflict2 = _interopRequireDefault(_handlebarsNoConflict);
var _create = _handlebarsRuntime2['default'].create;
function create() {
@@ -176,11 +176,11 @@
var base = _interopRequireWildcard(_handlebarsBase);
// Each of these augment the Handlebars object. No need to setup here.
// (This is done to easily share code between commonjs and browse envs)
- var _handlebarsSafeString = __webpack_require__(33);
+ var _handlebarsSafeString = __webpack_require__(37);
var _handlebarsSafeString2 = _interopRequireDefault(_handlebarsSafeString);
var _handlebarsException = __webpack_require__(6);
@@ -188,15 +188,15 @@
var _handlebarsUtils = __webpack_require__(5);
var Utils = _interopRequireWildcard(_handlebarsUtils);
- var _handlebarsRuntime = __webpack_require__(34);
+ var _handlebarsRuntime = __webpack_require__(38);
var runtime = _interopRequireWildcard(_handlebarsRuntime);
- var _handlebarsNoConflict = __webpack_require__(39);
+ var _handlebarsNoConflict = __webpack_require__(44);
var _handlebarsNoConflict2 = _interopRequireDefault(_handlebarsNoConflict);
// For compatibility and usage outside of module systems, make the Handlebars object a namespace
function create() {
@@ -274,11 +274,13 @@
var _logger = __webpack_require__(32);
var _logger2 = _interopRequireDefault(_logger);
- var VERSION = '4.5.3';
+ var _internalProtoAccess = __webpack_require__(33);
+
+ var VERSION = '4.7.3';
exports.VERSION = VERSION;
var COMPILER_REVISION = 8;
exports.COMPILER_REVISION = COMPILER_REVISION;
var LAST_COMPATIBLE_COMPILER_REVISION = 7;
@@ -350,10 +352,17 @@
this.decorators[name] = fn;
}
},
unregisterDecorator: function unregisterDecorator(name) {
delete this.decorators[name];
+ },
+ /**
+ * Reset the memory of illegal property accesses that have already been logged.
+ * @deprecated should only be used in handlebars test-cases
+ */
+ resetLoggedPropertyAccesses: function resetLoggedPropertyAccesses() {
+ _internalProtoAccess.resetLoggedProperties();
}
};
var log = _logger2['default'].log;
@@ -373,11 +382,10 @@
exports.escapeExpression = escapeExpression;
exports.isEmpty = isEmpty;
exports.createFrame = createFrame;
exports.blockParams = blockParams;
exports.appendContextPath = appendContextPath;
-
var escape = {
'&': '&',
'<': '<',
'>': '>',
'"': '"',
@@ -497,11 +505,10 @@
'use strict';
var _Object$defineProperty = __webpack_require__(7)['default'];
exports.__esModule = true;
-
var errorProps = ['description', 'fileName', 'lineNumber', 'endLineNumber', 'message', 'name', 'number', 'stack'];
function Exception(message, node) {
var loc = node && node.loc,
line = undefined,
@@ -1045,11 +1052,15 @@
instance.registerHelper('unless', function (conditional, options) {
if (arguments.length != 2) {
throw new _exception2['default']('#unless requires exactly one argument');
}
- return instance.helpers['if'].call(this, conditional, { fn: options.inverse, inverse: options.fn, hash: options.hash });
+ return instance.helpers['if'].call(this, conditional, {
+ fn: options.inverse,
+ inverse: options.fn,
+ hash: options.hash
+ });
});
};
module.exports = exports['default'];
@@ -1088,26 +1099,23 @@
/***/ (function(module, exports) {
'use strict';
exports.__esModule = true;
- var dangerousPropertyRegex = /^(constructor|__defineGetter__|__defineSetter__|__lookupGetter__|__proto__)$/;
- exports.dangerousPropertyRegex = dangerousPropertyRegex;
-
exports['default'] = function (instance) {
- instance.registerHelper('lookup', function (obj, field) {
+ instance.registerHelper('lookup', function (obj, field, options) {
if (!obj) {
+ // Note for 5.0: Change to "obj == null" in 5.0
return obj;
}
- if (dangerousPropertyRegex.test(String(field)) && !Object.prototype.propertyIsEnumerable.call(obj, field)) {
- return undefined;
- }
- return obj[field];
+ return options.lookupProperty(obj, field);
});
};
+ module.exports = exports['default'];
+
/***/ }),
/* 29 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
@@ -1236,12 +1244,12 @@
log: function log(level) {
level = logger.lookupLevel(level);
if (typeof console !== 'undefined' && logger.lookupLevel(logger.level) <= level) {
var method = logger.methodMap[level];
+ // eslint-disable-next-line no-console
if (!console[method]) {
- // eslint-disable-line no-console
method = 'log';
}
for (var _len = arguments.length, message = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
message[_key - 1] = arguments[_key];
@@ -1255,10 +1263,133 @@
exports['default'] = logger;
module.exports = exports['default'];
/***/ }),
/* 33 */
+/***/ (function(module, exports, __webpack_require__) {
+
+ 'use strict';
+
+ var _Object$create = __webpack_require__(34)['default'];
+
+ var _Object$keys = __webpack_require__(13)['default'];
+
+ var _interopRequireWildcard = __webpack_require__(3)['default'];
+
+ exports.__esModule = true;
+ exports.createProtoAccessControl = createProtoAccessControl;
+ exports.resultIsAllowed = resultIsAllowed;
+ exports.resetLoggedProperties = resetLoggedProperties;
+
+ var _createNewLookupObject = __webpack_require__(36);
+
+ var _logger = __webpack_require__(32);
+
+ var logger = _interopRequireWildcard(_logger);
+
+ var loggedProperties = _Object$create(null);
+
+ function createProtoAccessControl(runtimeOptions) {
+ var defaultMethodWhiteList = _Object$create(null);
+ defaultMethodWhiteList['constructor'] = false;
+ defaultMethodWhiteList['__defineGetter__'] = false;
+ defaultMethodWhiteList['__defineSetter__'] = false;
+ defaultMethodWhiteList['__lookupGetter__'] = false;
+
+ var defaultPropertyWhiteList = _Object$create(null);
+ // eslint-disable-next-line no-proto
+ defaultPropertyWhiteList['__proto__'] = false;
+
+ return {
+ properties: {
+ whitelist: _createNewLookupObject.createNewLookupObject(defaultPropertyWhiteList, runtimeOptions.allowedProtoProperties),
+ defaultValue: runtimeOptions.allowProtoPropertiesByDefault
+ },
+ methods: {
+ whitelist: _createNewLookupObject.createNewLookupObject(defaultMethodWhiteList, runtimeOptions.allowedProtoMethods),
+ defaultValue: runtimeOptions.allowProtoMethodsByDefault
+ }
+ };
+ }
+
+ function resultIsAllowed(result, protoAccessControl, propertyName) {
+ if (typeof result === 'function') {
+ return checkWhiteList(protoAccessControl.methods, propertyName);
+ } else {
+ return checkWhiteList(protoAccessControl.properties, propertyName);
+ }
+ }
+
+ function checkWhiteList(protoAccessControlForType, propertyName) {
+ if (protoAccessControlForType.whitelist[propertyName] !== undefined) {
+ return protoAccessControlForType.whitelist[propertyName] === true;
+ }
+ if (protoAccessControlForType.defaultValue !== undefined) {
+ return protoAccessControlForType.defaultValue;
+ }
+ logUnexpecedPropertyAccessOnce(propertyName);
+ return false;
+ }
+
+ function logUnexpecedPropertyAccessOnce(propertyName) {
+ if (loggedProperties[propertyName] !== true) {
+ loggedProperties[propertyName] = true;
+ logger.log('error', 'Handlebars: Access has been denied to resolve the property "' + propertyName + '" because it is not an "own property" of its parent.\n' + 'You can add a runtime option to disable the check or this warning:\n' + 'See https://handlebarsjs.com/api-reference/runtime-options.html#options-to-control-prototype-access for details');
+ }
+ }
+
+ function resetLoggedProperties() {
+ _Object$keys(loggedProperties).forEach(function (propertyName) {
+ delete loggedProperties[propertyName];
+ });
+ }
+
+/***/ }),
+/* 34 */
+/***/ (function(module, exports, __webpack_require__) {
+
+ module.exports = { "default": __webpack_require__(35), __esModule: true };
+
+/***/ }),
+/* 35 */
+/***/ (function(module, exports, __webpack_require__) {
+
+ var $ = __webpack_require__(9);
+ module.exports = function create(P, D){
+ return $.create(P, D);
+ };
+
+/***/ }),
+/* 36 */
+/***/ (function(module, exports, __webpack_require__) {
+
+ 'use strict';
+
+ var _Object$create = __webpack_require__(34)['default'];
+
+ exports.__esModule = true;
+ exports.createNewLookupObject = createNewLookupObject;
+
+ var _utils = __webpack_require__(5);
+
+ /**
+ * Create a new object with "null"-prototype to avoid truthy results on prototype properties.
+ * The resulting object can be used with "object[property]" to check if a property exists
+ * @param {...object} sources a varargs parameter of source objects that will be merged
+ * @returns {object}
+ */
+
+ function createNewLookupObject() {
+ for (var _len = arguments.length, sources = Array(_len), _key = 0; _key < _len; _key++) {
+ sources[_key] = arguments[_key];
+ }
+
+ return _utils.extend.apply(undefined, [_Object$create(null)].concat(sources));
+ }
+
+/***/ }),
+/* 37 */
/***/ (function(module, exports) {
// Build out our basic SafeString type
'use strict';
@@ -1273,17 +1404,19 @@
exports['default'] = SafeString;
module.exports = exports['default'];
/***/ }),
-/* 34 */
+/* 38 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
- var _Object$seal = __webpack_require__(35)['default'];
+ var _Object$seal = __webpack_require__(39)['default'];
+ var _Object$keys = __webpack_require__(13)['default'];
+
var _interopRequireWildcard = __webpack_require__(3)['default'];
var _interopRequireDefault = __webpack_require__(1)['default'];
exports.__esModule = true;
@@ -1304,10 +1437,14 @@
var _base = __webpack_require__(4);
var _helpers = __webpack_require__(10);
+ var _internalWrapHelper = __webpack_require__(43);
+
+ var _internalProtoAccess = __webpack_require__(33);
+
function checkRevision(compilerInfo) {
var compilerRevision = compilerInfo && compilerInfo[0] || 1,
currentRevision = _base.COMPILER_REVISION;
if (compilerRevision >= _base.LAST_COMPATIBLE_COMPILER_REVISION && compilerRevision <= _base.COMPILER_REVISION) {
@@ -1323,11 +1460,10 @@
throw new _exception2['default']('Template was precompiled with a newer version of Handlebars than the current runtime. ' + 'Please update your runtime to a newer version (' + compilerInfo[1] + ').');
}
}
function template(templateSpec, env) {
-
/* istanbul ignore next */
if (!env) {
throw new _exception2['default']('No environment passed to template');
}
if (!templateSpec || !templateSpec.main) {
@@ -1350,17 +1486,20 @@
options.ids[0] = true;
}
}
partial = env.VM.resolvePartial.call(this, partial, context, options);
- var optionsWithHooks = Utils.extend({}, options, { hooks: this.hooks });
+ var extendedOptions = Utils.extend({}, options, {
+ hooks: this.hooks,
+ protoAccessControl: this.protoAccessControl
+ });
- var result = env.VM.invokePartial.call(this, partial, context, optionsWithHooks);
+ var result = env.VM.invokePartial.call(this, partial, context, extendedOptions);
if (result == null && env.compile) {
options.partials[options.name] = env.compile(partial, templateSpec.compilerOptions, env);
- result = options.partials[options.name](context, optionsWithHooks);
+ result = options.partials[options.name](context, extendedOptions);
}
if (result != null) {
if (options.indent) {
var lines = result.split('\n');
for (var i = 0, l = lines.length; i < l; i++) {
@@ -1380,18 +1519,35 @@
// Just add water
var container = {
strict: function strict(obj, name, loc) {
if (!obj || !(name in obj)) {
- throw new _exception2['default']('"' + name + '" not defined in ' + obj, { loc: loc });
+ throw new _exception2['default']('"' + name + '" not defined in ' + obj, {
+ loc: loc
+ });
}
return obj[name];
},
+ lookupProperty: function lookupProperty(parent, propertyName) {
+ var result = parent[propertyName];
+ if (result == null) {
+ return result;
+ }
+ if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
+ return result;
+ }
+
+ if (_internalProtoAccess.resultIsAllowed(result, container.protoAccessControl, propertyName)) {
+ return result;
+ }
+ return undefined;
+ },
lookup: function lookup(depths, name) {
var len = depths.length;
for (var i = 0; i < len; i++) {
- if (depths[i] && depths[i][name] != null) {
+ var result = depths[i] && container.lookupProperty(depths[i], name);
+ if (result != null) {
return depths[i][name];
}
}
},
lambda: function lambda(current, context) {
@@ -1423,10 +1579,19 @@
while (value && depth--) {
value = value._parent;
}
return value;
},
+ mergeIfNeeded: function mergeIfNeeded(param, common) {
+ var obj = param || common;
+
+ if (param && common && param !== common) {
+ obj = Utils.extend({}, common, param);
+ }
+
+ return obj;
+ },
// An empty object to use as replacement for null-contexts
nullContext: _Object$seal({}),
noop: env.VM.noop,
compilerInfo: templateSpec.compiler
@@ -1452,32 +1617,39 @@
}
function main(context /*, options*/) {
return '' + templateSpec.main(container, context, container.helpers, container.partials, data, blockParams, depths);
}
+
main = executeDecorators(templateSpec.main, main, container, options.depths || [], data, blockParams);
return main(context, options);
}
+
ret.isTop = true;
ret._setup = function (options) {
if (!options.partial) {
- container.helpers = Utils.extend({}, env.helpers, options.helpers);
+ var mergedHelpers = Utils.extend({}, env.helpers, options.helpers);
+ wrapHelpersToPassLookupProperty(mergedHelpers, container);
+ container.helpers = mergedHelpers;
if (templateSpec.usePartial) {
- container.partials = Utils.extend({}, env.partials, options.partials);
+ // Use mergeIfNeeded here to prevent compiling global partials multiple times
+ container.partials = container.mergeIfNeeded(options.partials, env.partials);
}
if (templateSpec.usePartial || templateSpec.useDecorators) {
container.decorators = Utils.extend({}, env.decorators, options.decorators);
}
container.hooks = {};
+ container.protoAccessControl = _internalProtoAccess.createProtoAccessControl(options);
var keepHelperInHelpers = options.allowCallsToHelperMissing || templateWasPrecompiledWithCompilerV7;
_helpers.moveHelperToHooks(container, 'helperMissing', keepHelperInHelpers);
_helpers.moveHelperToHooks(container, 'blockHelperMissing', keepHelperInHelpers);
} else {
+ container.protoAccessControl = options.protoAccessControl; // internal option
container.helpers = options.helpers;
container.partials = options.partials;
container.decorators = options.decorators;
container.hooks = options.hooks;
}
@@ -1594,53 +1766,89 @@
Utils.extend(prog, props);
}
return prog;
}
+ function wrapHelpersToPassLookupProperty(mergedHelpers, container) {
+ _Object$keys(mergedHelpers).forEach(function (helperName) {
+ var helper = mergedHelpers[helperName];
+ mergedHelpers[helperName] = passLookupPropertyOption(helper, container);
+ });
+ }
+
+ function passLookupPropertyOption(helper, container) {
+ var lookupProperty = container.lookupProperty;
+ return _internalWrapHelper.wrapHelper(helper, function (options) {
+ return Utils.extend({ lookupProperty: lookupProperty }, options);
+ });
+ }
+
/***/ }),
-/* 35 */
+/* 39 */
/***/ (function(module, exports, __webpack_require__) {
- module.exports = { "default": __webpack_require__(36), __esModule: true };
+ module.exports = { "default": __webpack_require__(40), __esModule: true };
/***/ }),
-/* 36 */
+/* 40 */
/***/ (function(module, exports, __webpack_require__) {
- __webpack_require__(37);
+ __webpack_require__(41);
module.exports = __webpack_require__(21).Object.seal;
/***/ }),
-/* 37 */
+/* 41 */
/***/ (function(module, exports, __webpack_require__) {
// 19.1.2.17 Object.seal(O)
- var isObject = __webpack_require__(38);
+ var isObject = __webpack_require__(42);
__webpack_require__(18)('seal', function($seal){
return function seal(it){
return $seal && isObject(it) ? $seal(it) : it;
};
});
/***/ }),
-/* 38 */
+/* 42 */
/***/ (function(module, exports) {
module.exports = function(it){
return typeof it === 'object' ? it !== null : typeof it === 'function';
};
/***/ }),
-/* 39 */
+/* 43 */
/***/ (function(module, exports) {
- /* WEBPACK VAR INJECTION */(function(global) {/* global window */
'use strict';
exports.__esModule = true;
+ exports.wrapHelper = wrapHelper;
+ function wrapHelper(helper, transformOptionsFn) {
+ if (typeof helper !== 'function') {
+ // This should not happen, but apparently it does in https://github.com/wycats/handlebars.js/issues/1639
+ // We try to make the wrapper least-invasive by not wrapping it, if the helper is not a function.
+ return helper;
+ }
+ var wrapper = function wrapper() /* dynamic arguments */{
+ var options = arguments[arguments.length - 1];
+ arguments[arguments.length - 1] = transformOptionsFn(options);
+ return helper.apply(this, arguments);
+ };
+ return wrapper;
+ }
+
+/***/ }),
+/* 44 */
+/***/ (function(module, exports) {
+
+ /* WEBPACK VAR INJECTION */(function(global) {'use strict';
+
+ exports.__esModule = true;
+
exports['default'] = function (Handlebars) {
/* istanbul ignore next */
var root = typeof global !== 'undefined' ? global : window,
$Handlebars = root.Handlebars;
/* istanbul ignore next */
@@ -1654,11 +1862,11 @@
module.exports = exports['default'];
/* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
/***/ }),
-/* 40 */
+/* 45 */
/***/ (function(module, exports) {
'use strict';
exports.__esModule = true;
@@ -1689,11 +1897,11 @@
// must modify the object to operate properly.
exports['default'] = AST;
module.exports = exports['default'];
/***/ }),
-/* 41 */
+/* 46 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var _interopRequireDefault = __webpack_require__(1)['default'];
@@ -1702,19 +1910,19 @@
exports.__esModule = true;
exports.parseWithoutProcessing = parseWithoutProcessing;
exports.parse = parse;
- var _parser = __webpack_require__(42);
+ var _parser = __webpack_require__(47);
var _parser2 = _interopRequireDefault(_parser);
- var _whitespaceControl = __webpack_require__(43);
+ var _whitespaceControl = __webpack_require__(48);
var _whitespaceControl2 = _interopRequireDefault(_whitespaceControl);
- var _helpers = __webpack_require__(45);
+ var _helpers = __webpack_require__(50);
var Helpers = _interopRequireWildcard(_helpers);
var _utils = __webpack_require__(5);
@@ -1747,11 +1955,11 @@
return strip.accept(ast);
}
/***/ }),
-/* 42 */
+/* 47 */
/***/ (function(module, exports) {
// File ignored in coverage tests via setting in .istanbul.yml
/* Jison generated parser */
"use strict";
@@ -2488,20 +2696,20 @@
return new Parser();
})();exports["default"] = handlebars;
module.exports = exports["default"];
/***/ }),
-/* 43 */
+/* 48 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var _interopRequireDefault = __webpack_require__(1)['default'];
exports.__esModule = true;
- var _visitor = __webpack_require__(44);
+ var _visitor = __webpack_require__(49);
var _visitor2 = _interopRequireDefault(_visitor);
function WhitespaceControl() {
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
@@ -2712,11 +2920,11 @@
exports['default'] = WhitespaceControl;
module.exports = exports['default'];
/***/ }),
-/* 44 */
+/* 49 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var _interopRequireDefault = __webpack_require__(1)['default'];
@@ -2855,11 +3063,11 @@
exports['default'] = Visitor;
module.exports = exports['default'];
/***/ }),
-/* 45 */
+/* 50 */
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var _interopRequireDefault = __webpack_require__(1)['default'];
@@ -3086,18 +3294,18 @@
loc: this.locInfo(locInfo)
};
}
/***/ }),
-/* 46 */
+/* 51 */
/***/ (function(module, exports, __webpack_require__) {
/* eslint-disable new-cap */
'use strict';
- var _Object$create = __webpack_require__(47)['default'];
+ var _Object$create = __webpack_require__(34)['default'];
var _interopRequireDefault = __webpack_require__(1)['default'];
exports.__esModule = true;
exports.Compiler = Compiler;
@@ -3108,11 +3316,11 @@
var _exception2 = _interopRequireDefault(_exception);
var _utils = __webpack_require__(5);
- var _ast = __webpack_require__(40);
+ var _ast = __webpack_require__(45);
var _ast2 = _interopRequireDefault(_ast);
var slice = [].slice;
@@ -3163,18 +3371,18 @@
this.trackIds = options.trackIds;
options.blockParams = options.blockParams || [];
options.knownHelpers = _utils.extend(_Object$create(null), {
- 'helperMissing': true,
- 'blockHelperMissing': true,
- 'each': true,
+ helperMissing: true,
+ blockHelperMissing: true,
+ each: true,
'if': true,
- 'unless': true,
+ unless: true,
'with': true,
- 'log': true,
- 'lookup': true
+ log: true,
+ lookup: true
}, options.knownHelpers);
return this.accept(program);
},
@@ -3437,11 +3645,15 @@
this.opcode('popHash');
},
// HELPERS
opcode: function opcode(name) {
- this.opcodes.push({ opcode: name, args: slice.call(arguments, 1), loc: this.sourceNode[0].loc });
+ this.opcodes.push({
+ opcode: name,
+ args: slice.call(arguments, 1),
+ loc: this.sourceNode[0].loc
+ });
},
addDepth: function addDepth(depth) {
if (!depth) {
return;
@@ -3653,28 +3865,13 @@
};
}
}
/***/ }),
-/* 47 */
+/* 52 */
/***/ (function(module, exports, __webpack_require__) {
- module.exports = { "default": __webpack_require__(48), __esModule: true };
-
-/***/ }),
-/* 48 */
-/***/ (function(module, exports, __webpack_require__) {
-
- var $ = __webpack_require__(9);
- module.exports = function create(P, D){
- return $.create(P, D);
- };
-
-/***/ }),
-/* 49 */
-/***/ (function(module, exports, __webpack_require__) {
-
'use strict';
var _Object$keys = __webpack_require__(13)['default'];
var _interopRequireDefault = __webpack_require__(1)['default'];
@@ -3687,39 +3884,25 @@
var _exception2 = _interopRequireDefault(_exception);
var _utils = __webpack_require__(5);
- var _codeGen = __webpack_require__(50);
+ var _codeGen = __webpack_require__(53);
var _codeGen2 = _interopRequireDefault(_codeGen);
- var _helpersLookup = __webpack_require__(28);
-
function Literal(value) {
this.value = value;
}
function JavaScriptCompiler() {}
JavaScriptCompiler.prototype = {
// PUBLIC API: You can override these methods in a subclass to provide
// alternative compiled forms for name lookup and buffering semantics
- nameLookup: function nameLookup(parent, name /* , type*/) {
- if (_helpersLookup.dangerousPropertyRegex.test(name)) {
- var isEnumerable = [this.aliasable('container.propertyIsEnumerable'), '.call(', parent, ',', JSON.stringify(name), ')'];
- return ['(', isEnumerable, '?', _actualLookup(), ' : undefined)'];
- }
- return _actualLookup();
-
- function _actualLookup() {
- if (JavaScriptCompiler.isValidJavaScriptVariableName(name)) {
- return [parent, '.', name];
- } else {
- return [parent, '[', JSON.stringify(name), ']'];
- }
- }
+ nameLookup: function nameLookup(parent, name /*, type */) {
+ return this.internalNameLookup(parent, name);
},
depthedLookup: function depthedLookup(name) {
return [this.aliasable('container.lookup'), '(depths, "', name, '")'];
},
@@ -3751,11 +3934,17 @@
initializeBuffer: function initializeBuffer() {
return this.quotedString('');
},
// END PUBLIC API
+ internalNameLookup: function internalNameLookup(parent, name) {
+ this.lookupPropertyFunctionIsUsed = true;
+ return ['lookupProperty(', parent, ',', JSON.stringify(name), ')'];
+ },
+ lookupPropertyFunctionIsUsed: false,
+
compile: function compile(environment, options, context, asObject) {
this.environment = environment;
this.options = options;
this.stringParams = this.options.stringParams;
this.trackIds = this.options.trackIds;
@@ -3809,11 +3998,11 @@
}
if (!this.decorators.isEmpty()) {
this.useDecorators = true;
- this.decorators.prepend('var decorators = container.decorators;\n');
+ this.decorators.prepend(['var decorators = container.decorators, ', this.lookupPropertyFunctionVarDeclaration(), ';\n']);
this.decorators.push('return fn;');
if (asObject) {
this.decorators = Function.apply(this, ['fn', 'props', 'container', 'depth0', 'data', 'blockParams', 'depths', this.decorators.merge()]);
} else {
@@ -3922,10 +4111,14 @@
varDeclarations += ', alias' + ++aliasCount + '=' + alias;
node.children[0] = 'alias' + aliasCount;
}
});
+ if (this.lookupPropertyFunctionIsUsed) {
+ varDeclarations += ', ' + this.lookupPropertyFunctionVarDeclaration();
+ }
+
var params = ['container', 'depth0', 'helpers', 'partials', 'data'];
if (this.useBlockParams || this.useDepths) {
params.push('blockParams');
}
@@ -4000,10 +4193,14 @@
}
return this.source.merge();
},
+ lookupPropertyFunctionVarDeclaration: function lookupPropertyFunctionVarDeclaration() {
+ return '\n lookupProperty = container.lookupProperty || function(parent, propertyName) {\n if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {\n return parent[propertyName];\n }\n return undefined\n }\n '.trim();
+ },
+
// [blockValue]
//
// On stack, before: hash, inverse, program, value
// On stack, after: return value of blockHelperMissing
//
@@ -4802,10 +4999,13 @@
for (var i = 0, l = reservedWords.length; i < l; i++) {
compilerWords[reservedWords[i]] = true;
}
})();
+ /**
+ * @deprecated May be removed in the next major version
+ */
JavaScriptCompiler.isValidJavaScriptVariableName = function (name) {
return !JavaScriptCompiler.RESERVED_WORDS[name] && /^[a-zA-Z_$][0-9a-zA-Z_$]*$/.test(name);
};
function strictLookup(requireTerminal, compiler, parts, type) {
@@ -4829,11 +5029,11 @@
exports['default'] = JavaScriptCompiler;
module.exports = exports['default'];
/***/ }),
-/* 50 */
+/* 53 */
/***/ (function(module, exports, __webpack_require__) {
/* global define */
'use strict';
@@ -5005,6 +5205,6 @@
module.exports = exports['default'];
/***/ })
/******/ ])
});
-;
+;
\ No newline at end of file