@@ -67,17 +67,6 @@ var _OPTS_PASSABLE_WITH_DATA_EXPRESS = _OPTS_PASSABLE_WITH_DATA.concat('cache');
67
67
var _BOM = / ^ \uFEFF / ;
68
68
var _JS_IDENTIFIER = / ^ [ a - z A - Z _ $ ] [ 0 - 9 a - z A - Z _ $ ] * $ / ;
69
69
70
- var createObj = function ( ) {
71
- if ( typeof Object . create !== 'function' ) {
72
- return function ( o ) {
73
- function F ( ) { }
74
- F . prototype = o ;
75
- return new F ( ) ;
76
- } ;
77
- }
78
- return Object . create ;
79
- } ( ) ;
80
-
81
70
/**
82
71
* EJS template function cache. This can be a LRU object from lru-cache NPM
83
72
* module. By default, it is {@link module:utils.cache}, a simple in-process
@@ -318,7 +307,7 @@ function fileLoader(filePath){
318
307
*/
319
308
320
309
function includeFile ( path , options ) {
321
- var opts = utils . shallowCopy ( createObj ( null ) , options ) ;
310
+ var opts = utils . shallowCopy ( utils . createNullProtoObjWherePossible ( ) , options ) ;
322
311
opts . filename = getIncludePath ( path , opts ) ;
323
312
if ( typeof options . includer === 'function' ) {
324
313
var includerResult = options . includer ( path , opts . filename ) ;
@@ -424,8 +413,8 @@ exports.compile = function compile(template, opts) {
424
413
*/
425
414
426
415
exports . render = function ( template , d , o ) {
427
- var data = d || createObj ( null ) ;
428
- var opts = o || createObj ( null ) ;
416
+ var data = d || utils . createNullProtoObjWherePossible ( ) ;
417
+ var opts = o || utils . createNullProtoObjWherePossible ( ) ;
429
418
430
419
// No options object -- if there are optiony names
431
420
// in the data, copy them to options
@@ -496,7 +485,7 @@ exports.renderFile = function () {
496
485
opts . filename = filename ;
497
486
}
498
487
else {
499
- data = createObj ( null ) ;
488
+ data = utils . createNullProtoObjWherePossible ( ) ;
500
489
}
501
490
502
491
return tryHandleCache ( opts , data , cb ) ;
@@ -518,8 +507,8 @@ exports.clearCache = function () {
518
507
} ;
519
508
520
509
function Template ( text , opts ) {
521
- opts = opts || createObj ( null ) ;
522
- var options = createObj ( null ) ;
510
+ opts = opts || utils . createNullProtoObjWherePossible ( ) ;
511
+ var options = utils . createNullProtoObjWherePossible ( ) ;
523
512
this . templateText = text ;
524
513
/** @type {string | null } */
525
514
this . mode = null ;
@@ -705,14 +694,14 @@ Template.prototype = {
705
694
// Adds a local `include` function which allows full recursive include
706
695
var returnedFn = opts . client ? fn : function anonymous ( data ) {
707
696
var include = function ( path , includeData ) {
708
- var d = utils . shallowCopy ( createObj ( null ) , data ) ;
697
+ var d = utils . shallowCopy ( utils . createNullProtoObjWherePossible ( ) , data ) ;
709
698
if ( includeData ) {
710
699
d = utils . shallowCopy ( d , includeData ) ;
711
700
}
712
701
return includeFile ( path , opts ) ( d ) ;
713
702
} ;
714
703
return fn . apply ( opts . context ,
715
- [ data || createObj ( null ) , escapeFn , include , rethrow ] ) ;
704
+ [ data || utils . createNullProtoObjWherePossible ( ) , escapeFn , include , rethrow ] ) ;
716
705
} ;
717
706
if ( opts . filename && typeof Object . defineProperty === 'function' ) {
718
707
var filename = opts . filename ;
0 commit comments