Code Monkey home page Code Monkey logo

Comments (7)

kangax avatar kangax commented on September 2, 2024

Are U+200C and U+200D (from all the allowed characters) the only ones that fail in some clients at the moment?

from compat-table.

kangax avatar kangax commented on September 2, 2024

Not significant, but maybe:

var supportsZeroWidth = (function() {
  try {
    return eval('_\u200c\u200d = true');
  } catch(e) { }
}());

from compat-table.

mathiasbynens avatar mathiasbynens commented on September 2, 2024

U+200C and U+200D are the only two characters that haven’t changed categories since Unicode 3.0 yet still fail in multiple browsers, even though they’re explicitly mentioned in the spec. (Btw, I fixed the U+200C/U+200D bugs in V8 and WebKit/JavaScriptCore now.)

It’s funny, really; most browsers that claimed full ES5-compliance months ago still fail on a simple var a\u200c\u200d — only stable versions of IE9 and Firefox 10 get it right.

Other than those characters, the spec mentions the Unicode categories that are allowed in IdentifierStart and IdentifierPart — but that’s a separate issue. Of course, not all JavaScript engines have the same level of Unicode support yet. As the spec says:

ECMAScript implementations may recognize identifier characters defined in later editions of the Unicode Standard. If portability is a concern, programmers should only employ identifier characters defined in Unicode 3.0.

So no, there are lots of other identifiers that fail in multiple browsers at the moment, but these are one of the few characters that are explicitly mentioned in the ES5 spec (not deferred to a Unicode spec) yet they still fail. See the list of links to browser bugs in my post — only Firefox nightly seems to have full Unicode 6.1.0 support.

Nice simplification of the feature test!

from compat-table.

kangax avatar kangax commented on September 2, 2024

I see... So if we only consider Unicode 3.0, do implementations fare well with all the allowed characters?

from compat-table.

mathiasbynens avatar mathiasbynens commented on September 2, 2024

Other than the ZWJ and ZWNJ characters, I haven’t found a problem with non-Unicode 3.0 chars in any browser. As I tested some seriously crazy symbols, I doubt there are any. (I mostly tested browser implementations, though.)

The variable name validator might be useful when testing this further, as it will show a warning if a given identifier would not be allowed if the Unicode 3 database would’ve been used instead of the Unicode 6.1 database. E.g. http://mothereff.in/js-variables#%5Cu0cf1

from compat-table.

kangax avatar kangax commented on September 2, 2024

Yeah. I'm surprised test262 didn't catch that. Need to check if they test for it.

from compat-table.

kangax avatar kangax commented on September 2, 2024

Added. Thanks.

from compat-table.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.