@@ -67,17 +67,6 @@ var _OPTS_PASSABLE_WITH_DATA_EXPRESS = _OPTS_PASSABLE_WITH_DATA.concat('cache');
6767var _BOM = / ^ \uFEFF / ;
6868var _JS_IDENTIFIER = / ^ [ a - z A - Z _ $ ] [ 0 - 9 a - z A - Z _ $ ] * $ / ;
6969
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-
8170/**
8271 * EJS template function cache. This can be a LRU object from lru-cache NPM
8372 * module. By default, it is {@link module:utils.cache}, a simple in-process
@@ -318,7 +307,7 @@ function fileLoader(filePath){
318307 */
319308
320309function includeFile ( path , options ) {
321- var opts = utils . shallowCopy ( createObj ( null ) , options ) ;
310+ var opts = utils . shallowCopy ( utils . createNullProtoObjWherePossible ( ) , options ) ;
322311 opts . filename = getIncludePath ( path , opts ) ;
323312 if ( typeof options . includer === 'function' ) {
324313 var includerResult = options . includer ( path , opts . filename ) ;
@@ -424,8 +413,8 @@ exports.compile = function compile(template, opts) {
424413 */
425414
426415exports . 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 ( ) ;
429418
430419 // No options object -- if there are optiony names
431420 // in the data, copy them to options
@@ -496,7 +485,7 @@ exports.renderFile = function () {
496485 opts . filename = filename ;
497486 }
498487 else {
499- data = createObj ( null ) ;
488+ data = utils . createNullProtoObjWherePossible ( ) ;
500489 }
501490
502491 return tryHandleCache ( opts , data , cb ) ;
@@ -518,8 +507,8 @@ exports.clearCache = function () {
518507} ;
519508
520509function Template ( text , opts ) {
521- opts = opts || createObj ( null ) ;
522- var options = createObj ( null ) ;
510+ opts = opts || utils . createNullProtoObjWherePossible ( ) ;
511+ var options = utils . createNullProtoObjWherePossible ( ) ;
523512 this . templateText = text ;
524513 /** @type {string | null } */
525514 this . mode = null ;
@@ -705,14 +694,14 @@ Template.prototype = {
705694 // Adds a local `include` function which allows full recursive include
706695 var returnedFn = opts . client ? fn : function anonymous ( data ) {
707696 var include = function ( path , includeData ) {
708- var d = utils . shallowCopy ( createObj ( null ) , data ) ;
697+ var d = utils . shallowCopy ( utils . createNullProtoObjWherePossible ( ) , data ) ;
709698 if ( includeData ) {
710699 d = utils . shallowCopy ( d , includeData ) ;
711700 }
712701 return includeFile ( path , opts ) ( d ) ;
713702 } ;
714703 return fn . apply ( opts . context ,
715- [ data || createObj ( null ) , escapeFn , include , rethrow ] ) ;
704+ [ data || utils . createNullProtoObjWherePossible ( ) , escapeFn , include , rethrow ] ) ;
716705 } ;
717706 if ( opts . filename && typeof Object . defineProperty === 'function' ) {
718707 var filename = opts . filename ;
0 commit comments