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

Simplify script’s footer #1066

Closed
wants to merge 1 commit into from
Closed

Simplify script’s footer #1066

wants to merge 1 commit into from

Conversation

mina86
Copy link

@mina86 mina86 commented Feb 20, 2018

  1. ‘typeof foo === "undefined"’ is just a convoluted way of writing
    ‘foo === undefined’. The slight risk of ‘undefined’ being redefined
    (since it’s not a keyword) can be easily averted by using ‘void 0’.
    In the end, ‘typeof foo === "undefined"’ becomes ‘foo === void 0’
    which is shorter and does the same thing.

  2. There is really no need to use Function.prototype.call. Since the
    wrapper function uses it’s ‘this’ variable exactly once, whatever
    function run as call argument does can be moved inside of the wrapper.

This shortens and simplifies script’s footer.

1. ‘typeof foo === "undefined"’ is just a convoluted way of writing
   ‘foo === undefined’.  The slight risk of ‘undefined’ being redefined
   (since it’s not a keyword) can be easily averted by using ‘void 0’.
   In the end, ‘typeof foo === "undefined"’ becomes ‘foo === void 0’
   which is shorter and does the same thing.

2. There is really no need to use Function.prototype.call.  Since the
   wrapper function uses it’s ‘this’ variable exactly once, whatever
   function run as call argument does can be moved inside of the wrapper.

This shortens and simplifies script’s footer.
@UziTech
Copy link
Member

UziTech commented Feb 20, 2018

Thank you for your interest in marked.

We will be making a lot of changes to the code base in the future to make marked more modular so I'm sorry to say that these changes won't be needed. Read #1051 if you haven't already.

@UziTech UziTech closed this Feb 20, 2018
@Feder1co5oave
Copy link
Contributor

@mina86

I'd like to answer about the technicalities of the pull request:

  1. It seems the typeof === 'undefined' check is the de-facto standard and is considered the 100% safe way to check for undefinedness so we'll keep it that way. Plus I really don't think doing === void 0 is more readable than the former, but actually worse.

  2. I recognize the umd boilerplate currently in place is awful and I rewrote it in my PR [linting] Use eslint to lint code. + minor refactoring + Travis CI setup #1020.
    Look at ad6484b to get an idea and feel free to put in any feedback you have.

Cheers

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

Successfully merging this pull request may close these issues.

None yet

3 participants