Skip to content

Commit

Permalink
Expose ieCompat option present in LESS 1.4.0
Browse files Browse the repository at this point in the history
For more information
less/less.js#1190

Closes gh-53.
  • Loading branch information
sfarthin authored and Tyler Kellen committed Jun 12, 2013
1 parent cda757c commit 781fb61
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 2 deletions.
18 changes: 18 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,24 @@ module.exports = function(grunt) {
'tmp/yuicompress.css': ['test/fixtures/style.less']
}
},
ieCompatTrue: {
options: {
paths: ['test/fixtures/include'],
ieCompat: true
},
files: {
'tmp/ieCompatTrue.css': ['test/fixtures/ieCompat.less']
}
},
ieCompatFalse: {
options: {
paths: ['test/fixtures/include'],
ieCompat: false
},
files: {
'tmp/ieCompatFalse.css': ['test/fixtures/ieCompat.less']
}
},
nofiles: {
},
nomatchedfiles: {
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ Default: False

Compress output using cssmin.js

#### ieCompat
Type: `Boolean`
Default: true

Enforce the css output is compatible with Internet Explorer 8.

For example, the [data-uri](https://github.com/cloudhead/less.js/pull/1086) function encodes a file in base64 encoding and embeds it into the generated CSS files as a data-URI. Because Internet Explorer 8 limits `data-uri`s to 32KB, the [ieCompat](https://github.com/cloudhead/less.js/pull/1190) option prevents `less` from exceeding this.

#### optimization
Type: `Integer`
Default: null
Expand Down Expand Up @@ -107,4 +115,4 @@ less: {

Task submitted by [Tyler Kellen](http://goingslowly.com/)

*This file was generated on Sun Jun 09 2013 09:38:44.*
*This file was generated on Tue Jun 11 2013 16:04:30.*
8 changes: 8 additions & 0 deletions docs/less-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ Default: False

Compress output using cssmin.js

## ieCompat
Type: `Boolean`
Default: true

Enforce the css output is compatible with Internet Explorer 8.

For example, the [data-uri](https://github.com/cloudhead/less.js/pull/1086) function encodes a file in base64 encoding and embeds it into the generated CSS files as a data-URI. Because Internet Explorer 8 limits `data-uri`s to 32KB, the [ieCompat](https://github.com/cloudhead/less.js/pull/1190) option prevents `less` from exceeding this.

## optimization
Type: `Integer`
Default: null
Expand Down
2 changes: 1 addition & 1 deletion tasks/less.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = function(grunt) {

var lessOptions = {
parse: ['paths', 'optimization', 'filename', 'strictImports', 'dumpLineNumbers'],
render: ['compress', 'yuicompress']
render: ['compress', 'yuicompress', 'ieCompat']
};

grunt.registerMultiTask('less', 'Compile LESS files to CSS', function() {
Expand Down
5 changes: 5 additions & 0 deletions test/expected/ieCompatFalse.css

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions test/expected/ieCompatTrue.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
body {
width: 288px;
height: 288px;
background: transparent url('include/bob.jpg') 0 0 no-repeat;
}
5 changes: 5 additions & 0 deletions test/fixtures/ieCompat.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
body {
width: 288px;
height: 288px;
background: transparent data-uri('include/bob.jpg') 0 0 no-repeat;
}
Binary file added test/fixtures/include/bob.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions test/less_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,23 @@ exports.less = {
var expected = grunt.file.read('test/expected/yuicompress.css');
test.equal(expected, actual, 'should yuicompress output when yuicompress option is true');

test.done();
},
ieCompat: function(test) {
'use strict';

var actual, expected;

test.expect(2);

actual = grunt.file.read('tmp/ieCompatFalse.css');
expected = grunt.file.read('test/expected/ieCompatFalse.css');
test.equal(expected, actual, 'should generate data-uris no matter the size when ieCompat option is true');

actual = grunt.file.read('tmp/ieCompatTrue.css');
expected = grunt.file.read('test/expected/ieCompatTrue.css');
test.equal(expected, actual, 'should generate data-uris only when under the 32KB mark for Internet Explorer 8');

test.done();
}
};

0 comments on commit 781fb61

Please sign in to comment.