ejs icon indicating copy to clipboard operation
ejs copied to clipboard

IE8 does not support trim()

Open abrkn opened this issue 13 years ago • 9 comments

Object doesn't support property or method 'trim'

abrkn avatar Nov 26 '12 09:11 abrkn

got some example code?

ralyodio avatar Nov 26 '12 19:11 ralyodio

we can swap with a quick regexp

tj avatar Nov 28 '12 00:11 tj

got some example code?

'got some example code?'.trim()

https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/Trim

s.replace(/^\s+|\s+$/g,'')

abrkn avatar Nov 28 '12 12:11 abrkn

IE8 does not support .map or .reduce either. It sucks, but is still a widely used browser. Would you include code that makes ejs IE8 compatible?

abrkn avatar Jun 22 '13 13:06 abrkn

This is biting me now, too. I can't imagine IE is the primary use case, but any chance this can be updated? I'm happy to send the code over in a PR if you're open.

jeffharrell avatar Nov 03 '13 01:11 jeffharrell

Why don't you just use a shim?

if (!String.prototype.trim) {
  String.prototype.trim = function () {
    return this.replace(/^\s+|\s+$/g,'');
  }
}

Why should this be the responsibility of the library author?

ForbesLindesay avatar Nov 04 '13 11:11 ForbesLindesay

This was a compatibility question. If EJS is intended to support IE 8 then it is the responsibility of the library owner. This is even referenced at https://github.com/visionmedia/ejs/issues/89#issuecomment-10784998 .

If it's not intended to support IE 8 then this issue should be closed and I'm happy to use a shim. It's worth asking first.

jeffharrell avatar Nov 04 '13 15:11 jeffharrell

IE8 is not mentioned anywhere in the readme, and it doesn't work on IE8, so I assume it doesn't support IE8.

ForbesLindesay avatar Nov 04 '13 15:11 ForbesLindesay

国外真幸福。。。2013年就开始说不支持 IE8 了~好吧,换一个。。。

fegg avatar Oct 19 '16 03:10 fegg