Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for feature detection #1

Open
fabiosantoscode opened this issue Jan 31, 2016 · 0 comments
Open

Allow for feature detection #1

fabiosantoscode opened this issue Jan 31, 2016 · 0 comments

Comments

@fabiosantoscode
Copy link
Owner

In javascript, it's very important to detect what features you have access to.

In the case of js2cpp, we don't have things like a window or a document or a global (not yet, for another issue). Unfortunately the c++ compiler doesn't allow us to compile if dead code calls something that doesn't exist.

If someone writes some isomorphic code which contains a feature detection, for example:

if (typeof location !== 'undefined') { location.reload(); }

We should remove the entire condition if this feature is not present.

A new option, which lists what is defined in the global scope, should be defined. Early returns such as

if (typeof location !== 'undefined') { return; }
// use location...

should also remove the code that follows them.

@fabiosantoscode fabiosantoscode changed the title Enable feature detection Allow for feature detection Jan 31, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant