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

bad conversion of vars after usage #203

Closed
graingert opened this issue May 6, 2016 · 3 comments
Closed

bad conversion of vars after usage #203

graingert opened this issue May 6, 2016 · 3 comments

Comments

@graingert
Copy link

getComputedStyle = @getComputedStyle or \
  (el, pseudo) ->
    @getPropertyValue = (prop) ->
      prop = 'styleFloat' if prop is 'float'
      prop.replace(getComputedStyleRX, (_, _char)->
        _char.toUpperCase()
      ) if getComputedStyleRX.test prop
      currentStyle = el.currentStyle
      `(currentStyle != null ? currentStyle[prop] : void 0) || null`
    @
getComputedStyleRX = /(\-([a-z]){1})/g

becomes

  // getComputedStyle shim, from http://stackoverflow.com/a/21797294
  let getComputedStyle = this.getComputedStyle || 
    function(el, pseudo) {
      this.getPropertyValue = function(prop) {
        if (prop === 'float') { prop = 'styleFloat'; }
        if (getComputedStyleRX.test(prop)) { prop.replace(getComputedStyleRX, (_, _char)=> _char.toUpperCase()
        ); }
        let { currentStyle } = el;
        return (currentStyle != null ? currentStyle[prop] : void 0) || null;
      };
      return this;
    };
  getComputedStyleRX = /(\-([a-z]){1})/g;
@graingert
Copy link
Author

graingert commented May 6, 2016

should be:

  let getComputedStyleRX = /(\-([a-z]){1})/g;
  // getComputedStyle shim, from http://stackoverflow.com/a/21797294
  let getComputedStyle = this.getComputedStyle || 
    function(el, pseudo) {
      this.getPropertyValue = function(prop) {
        if (prop === 'float') { prop = 'styleFloat'; }
        if (getComputedStyleRX.test(prop)) { prop.replace(getComputedStyleRX, (_, _char)=> _char.toUpperCase()
        ); }
        let { currentStyle } = el;
        return (currentStyle != null ? currentStyle[prop] : void 0) || null;
      };
      return this;
    };

@eventualbuddha
Copy link
Collaborator

This is handled by add-variable-declarations and is tracked in eventualbuddha/add-variable-declarations#3.

@eventualbuddha
Copy link
Collaborator

eventualbuddha commented May 6, 2016

Fixed in v2.9.0 (repl).

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

2 participants