Prevent data-uri function from embedding files larger than 32KB.

Although IE8 does support data-uris, it only does so with a limit of 32KB. It's a silly limitation, but a source of potential bugs. When the limit is exceeded, the data-uri() function will simply return a normal url() value with a relative path to the asset.

One may pass --no-ie-compat to lessc to avoid this safeguard.
This commit is contained in:
Daniel Stockman
2013-02-18 18:54:11 -08:00
committed by Luke Page
parent 7116b3b1c5
commit e4fe935ea1
9 changed files with 39 additions and 0 deletions

View File

@@ -44,3 +44,6 @@
uri-1: url('http://localhost:8081/browser/less/../../data/page.html');
uri-2: url('http://localhost:8081/browser/less/../../data/page.html');
}
#data-uri-toobig {
uri: url('http://localhost:8081/browser/less/../../data/data-uri-fail.png');
}

View File

@@ -43,3 +43,7 @@
uri-1: data-uri('text/html', '../../data/page.html');
uri-2: data-uri('../../data/page.html');
}
#data-uri-toobig {
uri: data-uri('../../data/data-uri-fail.png');
}

View File

@@ -52,3 +52,6 @@
uri-1: url('data:text/html,%3Ch1%3EThis%20page%20is%20100%25%20Awesome.%3C%2Fh1%3E%0A');
uri-2: url('data:text/html,%3Ch1%3EThis%20page%20is%20100%25%20Awesome.%3C%2Fh1%3E%0A');
}
#data-uri-toobig {
uri: url(../data/data-uri-fail.png);
}

BIN
test/data/data-uri-fail.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

View File

@@ -46,3 +46,8 @@
uri-1: data-uri('text/html', '../data/page.html');
uri-2: data-uri('../data/page.html');
}
// so, weirdly, the browser output is quoted, the less output is UNquoted
#data-uri-toobig {
uri: data-uri('../data/data-uri-fail.png');
}