Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Using the '&'-operator after a subselector doesn't work as expected #5

Closed
marklagendijk opened this issue Nov 11, 2011 · 8 comments
Closed

Comments

@marklagendijk
Copy link

Using the ‘&’ operator after a selector doesn’t work properly. In the output the ‘&’ parts get places before the subselector instead of after it:

#main {
    #content {
        .class {
            position: absolute;
            #container & {
                position: relative;
            }
        }
    }
}

Should output:

#main #content .class { 
    position: absolute; 
}
#container #main #content .class { 
    position:relative; 
}

But this is what it does output:

#main #content .class { 
    position: absolute; 
}
#main #content .class #container { 
    position: relative; 
}

Note: this usage of the ‘&’-operator isn’t documented. In the documentation it only shows the operator being used before a selector. However, it does work when trying this example in the browswer.

@duncansmart
Copy link
Owner

Looks like a bug in the older (IE6/7) JScript engine mode which is what WScript uses for old script compatibility. Not sure there's a way of getting WScript to run JScript engine in newer, more standards-compliant mode. Perhaps researching what the differences are between the old and new JScript engine modes will indicate what the issue is in less.js itself so we could submit a patch.

@duncansmart
Copy link
Owner

Narrows it down http://blogs.msdn.com/b/jscript/archive/2009/04/17/versioning-language-features-in-jscript.aspx

  • Native JSON support – This would introduce a new built-in JSON object, and the following built-in methods – JSON.parse(), JSON.stringify(), Date.toJSON(), Number.toJSON(), Boolean.toJSON() and String.toJSON()
  • Support for accessor methods for enabling Document Object Model prototypes
  • Default the separator to “,” if the separator value is ‘undefined’ in Array.prototype.join
  • Return the length of the resultant array instead of ‘undefined’ for Array.prototype.unshift
  • Call toString() if precision is ‘undefined’ instead of throwing a “RangeError” for Number.prototype.toPrecision
  • Support for array subclassing
  • Support for trailing commas in object literals
  • Implemented Error.prototype.toString to provide better error messages
  • Support for index operator [] on string values

@marklagendijk
Copy link
Author

In the article you mention there is a part about: "JScript Versioning in other JScript Hosts (for JScript Host Developers)". Is this something that something that is usable in WScript? If so this would solve our problem. I can't find any documentation on using this in WScript, though.

@duncansmart
Copy link
Owner

No, don't think so. But based on that list of features worked out that the issue is "index operator [] on string values", or rather lack of it. Just submitting a patch to less.js now...

@marklagendijk
Copy link
Author

Cool!

@duncansmart
Copy link
Owner

Fixed in 622bc45

@duncansmart
Copy link
Owner

Note: this fix was included in less.js itself by @cloudhead in less/less.js@e808472.

Pull request: less/less.js#452

@marklagendijk
Copy link
Author

It is also included in the new release of less.js (1.1.5).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants