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

[BUGFIX release] Fix uglification introduced bug with super wrapping. #12463

Merged
merged 1 commit into from
Oct 9, 2015

Commits on Oct 8, 2015

  1. [BUGFIX release] Fix uglification introduced bug with super wrapping.

    We check to see if a function contains `_super` / `.call` / `.apply`
    before attempting to super wrap a given method (this saves quite a bit
    of extra super wrapping for functions that do not need it).
    Unfortunately, a number of platforms that we support do not support
    calling `func.toString()` so we attempt to detect this and fall back
    to always super wrap everything mode.
    
    We have roughly this code (from
    [here](https://github.com/emberjs/ember.js/blob/b4718218dbe5ffe7736c485a594248b20977c621/packages/ember-metal/lib/utils.js#L257-L271))
    to detect if we can call `toString()` and get the original source:
    
    ```javascript
      let sourceAvailable = (function() {
        return this;
      }).toString().indexOf('return this;') > -1;
    ```
    
    This works perfectly for development builds, but unfortunately not
    when minified.  Take a look at the minified source and you will see why:
    
    ```javascript
    var e=function(){return this}.toString().indexOf("return this;")>-1;
    ```
    
    Note that minifier has stripped the trailing semicolon from the function
    body we are attempting to check against, but sadly our `indexOf` check
    still contains the semicolon!
    
    **tldr;** We super wrap every function in uglified builds.
    
    ---
    
    This commit removes the trailing semicolon from the source check, and
    adds a test that should hopefully allow us to detect if this is
    accidentally reintroduced.
    rwjblue committed Oct 8, 2015
    Configuration menu
    Copy the full SHA
    7894cae View commit details
    Browse the repository at this point in the history