ravjot28 / esprima

Automatically exported from code.google.com/p/esprima
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

Support HTML comment syntax #451

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Details are here: http://javascript.spec.whatwg.org/#comment-syntax This is 
implemented in all JavaScript engines.

Original issue reported on code.google.com by mathias@qiwi.be on 5 Sep 2013 at 3:15

GoogleCodeExporter commented 9 years ago
Patch that adds support for the `<!--` comment syntax: 
https://github.com/ariya/esprima/pull/196

Original comment by mathias@qiwi.be on 5 Sep 2013 at 4:05

GoogleCodeExporter commented 9 years ago
More discussion threads on HTML-style comments support, to inform any decisions 
on this issue:

https://github.com/getify/literalizer/issues/19

https://github.com/marijnh/acorn/issues/62

https://github.com/mishoo/UglifyJS/issues/346

Original comment by get...@gmail.com on 5 Sep 2013 at 4:34

GoogleCodeExporter commented 9 years ago
TC-39 has stated many times via es-discuss that they write their spec to 
standardise JS-in-the-wild. If all browsers agree on it, you should ask TC-39 
to standardise it. None of these JS parser libraries should accept a language 
other than what is described in the version of ECMA-262 that they implement.

Original comment by mfica...@groupon.com on 5 Sep 2013 at 6:56

GoogleCodeExporter commented 9 years ago
It's apparently slated to standardize in ES6: 
http://people.mozilla.org/~jorendorff/es6-draft.html#sec-B.1.3

Original comment by get...@gmail.com on 5 Sep 2013 at 9:29

GoogleCodeExporter commented 9 years ago
In that case, I'd be okay accepting this syntax in the harmony branch.

Original comment by mfica...@groupon.com on 5 Sep 2013 at 9:49

GoogleCodeExporter commented 9 years ago
FWIW, this change landed in UglifyJS2: 
https://github.com/mishoo/UglifyJS2/commit/7c10b253462b0af3b8700e71ae2ae4aaac1a9
53e#commitcomment-4030529

Original comment by mathias@qiwi.be on 6 Sep 2013 at 8:42

GoogleCodeExporter commented 9 years ago
…and in Acorn: 
https://github.com/marijnh/acorn/commit/b998d5e22da7a422a7eb9d2ccd2740621ab94c4d

Original comment by mathias@qiwi.be on 6 Sep 2013 at 8:54

GoogleCodeExporter commented 9 years ago
I think it makes sense to support this HTML comment. The question is, should it 
be part of the normal behavior or only when tolerant = true?

Original comment by ariya.hi...@gmail.com on 6 Sep 2013 at 3:03

GoogleCodeExporter commented 9 years ago
Seeing as it works in all JavaScript engines, even in strict mode, my vote goes 
to supporting this syntax in all cases (not just in `tolerant` mode).

Original comment by mathias@qiwi.be on 6 Sep 2013 at 3:05

GoogleCodeExporter commented 9 years ago
The patch was merged in 
https://github.com/ariya/esprima/commit/38b068d55c3e2160479afeeddf5afa2d30ba6c2e
.

After this patch, only the `-->` syntax is left, but that one is a bit trickier 
(as it only takes effect when it’s the first token on the line, optionally 
preceeded by only whitespace or multiline comments).

Original comment by mathias@qiwi.be on 11 Sep 2013 at 11:17

GoogleCodeExporter commented 9 years ago
Support `<!--` comment syntax
https://github.com/ariya/esprima/commit/38b068d55c

Move the tests for HTML comment.
https://github.com/ariya/esprima/commit/2b7fca5ed1

Support --> HTML comment.
https://github.com/ariya/esprima/commit/40dc5f2d00

Original comment by ariya.hi...@gmail.com on 27 Sep 2013 at 3:12