[Pkg-javascript-commits] [less.js] 57/285: merge from master
Jonas Smedegaard
dr at jones.dk
Mon Oct 26 23:23:37 UTC 2015
This is an automated email from the git hooks/post-receive script.
js pushed a commit to annotated tag v2.0.0
in repository less.js.
commit f85f2535866af6d8fe3961110befb201b6fc9665
Merge: 3830278 466bc39
Author: Luke Page <luke.a.page at gmail.com>
Date: Thu Aug 14 17:27:16 2014 +0100
merge from master
CHANGELOG.md | 24 +-
Gruntfile.js | 12 -
README.md | 4 +-
benchmark/less-benchmark.js | 3 +-
bin/lessc | 16 +-
bower.json | 4 +-
build/README.md | 53 -
dist/less-1.7.3.js | 7942 +++++++++++++++++++++++++++
dist/less-1.7.3.min.js | 16 +
dist/less-1.7.4.js | 7979 +++++++++++++++++++++++++++
dist/less-1.7.4.min.js | 16 +
dist/less-rhino-1.7.3.js | 9317 +++++++++++++++++++++++++++++++
dist/less-rhino-1.7.4.js | 9354 ++++++++++++++++++++++++++++++++
dist/lessc-rhino-1.7.3.js | 449 ++
dist/lessc-rhino-1.7.4.js | 449 ++
lib/less/environment/browser.js | 2 +-
lib/less/environment/node.js | 2 +-
lib/less/functions.js | 9 +-
lib/less/parser.js | 44 +-
lib/less/tree/anonymous.js | 8 +-
lib/less/tree/combinator.js | 28 +-
lib/less/tree/directive.js | 6 +
lib/less/tree/element.js | 1 -
lib/less/tree/import.js | 2 +-
lib/less/tree/ruleset.js | 29 +-
lib/less/tree/selector.js | 2 +-
lib/less/visitor/import-visitor.js | 10 +-
lib/less/visitor/to-css-visitor.js | 3 +
package.json | 10 +-
test/browser/common.js | 4 +-
test/css/css-3.css | 6 +
test/css/import-inline.css | 5 +-
test/css/import.css | 6 +
test/css/mixins.css | 3 +
test/css/urls.css | 6 +
test/less-test.js | 15 +-
test/less/css-3.less | 7 +
test/less/errors/import-malformed.less | 1 +
test/less/errors/import-malformed.txt | 3 +
test/less/errors/import-no-semi.txt | 2 +-
test/less/import-inline.less | 1 +
test/less/import.less | 9 +-
test/less/mixins.less | 1 +
test/less/urls.less | 12 +
test/sourcemaps/basic.json | 2 +-
45 files changed, 35727 insertions(+), 150 deletions(-)
diff --cc CHANGELOG.md
index c233c33,c53ec14..a77138c
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@@ -1,16 -1,24 +1,36 @@@
+#2.0.0
+
+2014-??-??
+
+ - no longer including old versions of less in the repo or npm
+ - not including test and gradle files in npm (Note: TODO may need to move some test framework into lib for core plugins)
+ - colours now output in the format they are added unless compressing, so yellow will output yellow, not its hex counterpart
+ - better parsing - better comment support (TODO) and comments in brackets can now contain comments including quotes.
+TODO
+ - Environment Support
- - Finalised Plugin Support
-
++ - Finalised Plugin Support
++
+ # 1.7.4
+
+ 2014-07-27
+
+ - Handle uppercase paths in browser
+ - Show error if an empty selector is used in extend
+ - Fix property merging in directives
+ - Fix ordering of charset and import directives
+ - Fix race condition that caused a rules is undefined error sometimes if you had a complex import strategy
+ - Better error message for imports missing semi-colons or malformed
+ - Do not use util.print to avoid deprecate warnings in node 0.11
+
+ # 1.7.3
+
+ 2014-06-22
+
+ - Include dist files, missing from 1.7.2
+ - Do not round the results of color functions, like lightness, hue, luma etc.
+ - Support cover and contain keywords in background definitions
+
-# 1.7.2
+ # 1.7.2
2014-06-19
diff --cc Gruntfile.js
index 11b2093,ad977dc..a5000b8
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@@ -1,316 -1,286 +1,304 @@@
'use strict';
+var fs = require('fs');
-module.exports = function(grunt) {
+module.exports = function (grunt) {
- // Report the elapsed execution time of tasks.
- require('time-grunt')(grunt);
+ // Report the elapsed execution time of tasks.
+ require('time-grunt')(grunt);
- // Project configuration.
- grunt.initConfig({
+ // Project configuration.
+ grunt.initConfig({
- // Metadata required for build.
- build: grunt.file.readYAML('build/build.yml'),
- pkg: grunt.file.readJSON('package.json'),
- meta: {
- license: '<%= _.pluck(pkg.licenses, "type").join(", ") %>',
- copyright: 'Copyright (c) 2009-<%= grunt.template.today("yyyy") %>',
- banner:
- '/*!\n' +
- ' * Less - <%= pkg.description %> v<%= pkg.version %>\n' +
- ' * http://lesscss.org\n' +
- ' *\n' +
- ' * <%= meta.copyright %>, <%= pkg.author.name %> <<%= pkg.author.email %>>\n' +
- ' * Licensed under the <%= meta.license %> License.\n' +
- ' *\n' +
- ' */\n\n' +
- ' /**' +
- ' * @license <%= meta.license %>\n' +
- ' */\n\n'
- },
+ // Metadata required for build.
+ build: grunt.file.readYAML('build/build.yml'),
+ pkg: grunt.file.readJSON('package.json'),
+ meta: {
+ license: '<%= _.pluck(pkg.licenses, "type").join(", ") %>',
+ copyright: 'Copyright (c) 2009-<%= grunt.template.today("yyyy") %>',
+ banner: '/*!\n' +
+ ' * Less - <%= pkg.description %> v<%= pkg.version %>\n' +
+ ' * http://lesscss.org\n' +
+ ' *\n' +
+ ' * <%= meta.copyright %>, <%= pkg.author.name %> <<%= pkg.author.email %>>\n' +
+ ' * Licensed under the <%= meta.license %> License.\n' +
+ ' *\n' +
+ ' */\n\n' +
+ ' /**' +
+ ' * @license <%= meta.license %>\n' +
+ ' */\n\n'
+ },
+
+ shell: {
+ options: {stdout: true, failOnError: true},
+ test: {
+ command: 'node test'
+ },
+ benchmark: {
+ command: 'node benchmark/less-benchmark.js'
+ },
+ "browsertest-server": {
+ command: 'node node_modules/http-server/bin/http-server . -p 8088'
+ },
+ "sourcemap-test": {
+ command: [
+ 'node bin/lessc --source-map --source-map-map-inline test/less/import.less test/sourcemaps/import.css',
+ 'node bin/lessc --source-map --source-map-map-inline test/less/sourcemaps/basic.less test/sourcemaps/basic.css',
+ 'node node_modules/http-server/bin/http-server test/sourcemaps -p 8084'].join('&&')
+ }
+ },
- shell: {
- options: {stdout: true, failOnError: true},
- test: {
- command: 'node test'
- },
- benchmark: {
- command: 'node benchmark/less-benchmark.js'
- },
- "browsertest-server": {
- command: 'node node_modules/http-server/bin/http-server . -p 8088'
- },
- "sourcemap-test": {
- command: [
- 'node bin/lessc --source-map --source-map-map-inline test/less/import.less test/sourcemaps/import.css',
- 'node bin/lessc --source-map --source-map-map-inline test/less/sourcemaps/basic.less test/sourcemaps/basic.css',
- 'node node_modules/http-server/bin/http-server test/sourcemaps -p 8084'].join('&&')
- }
- },
- concat: {
- options: {
- stripBanners: 'all',
- banner: '<%= meta.banner %>\n\n(function (window, undefined) {',
- footer: '\n})(window);'
- },
- // Browser versions
- browsertest: {
- src: ['<%= build.browser %>'],
- dest: 'test/browser/less.js'
- },
- stable: {
- src: ['<%= build.browser %>'],
- dest: 'dist/less-<%= pkg.version %>.js'
- },
- // Rhino
- rhino: {
- options: {
- banner: '/* Less.js v<%= pkg.version %> RHINO | <%= meta.copyright %>, <%= pkg.author.name %> <<%= pkg.author.email %>> */\n\n',
- footer: '' // override task-level footer
+ browserify: {
+ browser: {
+ src: ['./lib/less/browser.js'],
+ dest: 'tmp/less.js'
+ }
},
- src: ['<%= build.rhino %>'],
- dest: 'dist/less-rhino-<%= pkg.version %>.js'
- },
- // lessc for Rhino
- rhinolessc: {
- options: {
- banner: '/* Less.js v<%= pkg.version %> RHINO | <%= meta.copyright %>, <%= pkg.author.name %> <<%= pkg.author.email %>> */\n\n',
- footer: '' // override task-level footer
+ concat: {
+ options: {
+ stripBanners: 'all',
+ banner: '<%= meta.banner %>'
+ },
+ browsertest: {
+ src: '<%= browserify.browser.dest %>',
+ dest: 'test/browser/less.js'
+ },
+ dist: {
+ src: '<%= browserify.browser.dest %>',
+ dest: 'dist/less.js'
+ },
+ // Rhino
+ rhino: {
+ options: {
+ banner: '/* Less.js v<%= pkg.version %> RHINO | <%= meta.copyright %>, <%= pkg.author.name %> <<%= pkg.author.email %>> */\n\n',
+ footer: '' // override task-level footer
+ },
+ src: ['<%= build.rhino %>'],
+ dest: 'dist/less-rhino.js'
+ },
+ // lessc for Rhino
+ rhinolessc: {
+ options: {
+ banner: '/* Less.js v<%= pkg.version %> RHINO | <%= meta.copyright %>, <%= pkg.author.name %> <<%= pkg.author.email %>> */\n\n',
+ footer: '' // override task-level footer
+ },
+ src: ['<%= build.rhinolessc %>'],
+ dest: 'dist/lessc-rhino.js'
- },
- // Generate readme
- readme: {
- // override task-level banner and footer
- options: {process: true, banner: '', footer: ''},
- src: ['build/README.md'],
- dest: 'README.md'
+ }
},
- src: ['<%= build.rhinolessc %>'],
- dest: 'dist/lessc-rhino-<%= pkg.version %>.js'
- }
- },
- uglify: {
- options: {
- banner: '<%= meta.banner %>',
- mangle: true
- },
- stable: {
- src: ['<%= concat.stable.dest %>'],
- dest: 'dist/less-<%= pkg.version %>.min.js'
- }
- },
+ uglify: {
+ options: {
+ banner: '<%= meta.banner %>',
+ mangle: true
+ },
+ dist: {
+ src: ['<%= concat.dist.dest %>'],
+ dest: 'dist/less.min.js'
+ }
+ },
- jshint: {
- options: {jshintrc: '.jshintrc'},
- files: {
- src: [
- 'Gruntfile.js',
- 'lib/less/**/*.js'
- ]
- }
- },
+ jshint: {
+ options: {jshintrc: '.jshintrc'},
+ files: {
+ src: [
+ 'Gruntfile.js',
+ 'lib/less/**/*.js',
+ 'bin/lessc'
+ ]
+ }
+ },
- connect: {
- server: {
- options: {
- port: 8081
- }
- }
- },
+ connect: {
+ server: {
+ options: {
+ port: 8081
+ }
+ }
+ },
- jasmine: {
- options: {
- // version: '2.0.0-rc2',
- keepRunner: true,
- host: 'http://localhost:8081/',
- vendor: ['test/browser/common.js', 'test/browser/less.js'],
- template: 'test/browser/test-runner-template.tmpl'
- },
- main: {
- // src is used to build list of less files to compile
- src: ['test/less/*.less', '!test/less/javascript.less', '!test/less/urls.less', '!test/less/empty.less'],
- options: {
- helpers: 'test/browser/runner-main-options.js',
- specs: 'test/browser/runner-main-spec.js',
- outfile: 'tmp/browser/test-runner-main.html'
- }
- },
- legacy: {
- src: ['test/less/legacy/*.less'],
- options: {
- helpers: 'test/browser/runner-legacy-options.js',
- specs: 'test/browser/runner-legacy-spec.js',
- outfile: 'tmp/browser/test-runner-legacy.html'
- }
- },
- errors: {
- src: ['test/less/errors/*.less', '!test/less/errors/javascript-error.less'],
- options: {
- timeout: 20000,
- helpers: 'test/browser/runner-errors-options.js',
- specs: 'test/browser/runner-errors-spec.js',
- outfile: 'tmp/browser/test-runner-errors.html'
- }
- },
- noJsErrors: {
- src: ['test/less/no-js-errors/*.less'],
- options: {
- helpers: 'test/browser/runner-no-js-errors-options.js',
- specs: 'test/browser/runner-no-js-errors-spec.js',
- outfile: 'tmp/browser/test-runner-no-js-errors.html'
- }
- },
- browser: {
- src: ['test/browser/less/*.less'],
- options: {
- helpers: 'test/browser/runner-browser-options.js',
- specs: 'test/browser/runner-browser-spec.js',
- outfile: 'tmp/browser/test-runner-browser.html'
- }
- },
- relativeUrls: {
- src: ['test/browser/less/relative-urls/*.less'],
- options: {
- helpers: 'test/browser/runner-relative-urls-options.js',
- specs: 'test/browser/runner-relative-urls-spec.js',
- outfile: 'tmp/browser/test-runner-relative-urls.html'
- }
- },
- rootpath: {
- src: ['test/browser/less/rootpath/*.less'],
- options: {
- helpers: 'test/browser/runner-rootpath-options.js',
- specs: 'test/browser/runner-rootpath-spec.js',
- outfile: 'tmp/browser/test-runner-rootpath.html'
- }
- },
- rootpathRelative: {
- src: ['test/browser/less/rootpath-relative/*.less'],
- options: {
- helpers: 'test/browser/runner-rootpath-relative-options.js',
- specs: 'test/browser/runner-rootpath-relative-spec.js',
- outfile: 'tmp/browser/test-runner-rootpath-relative.html'
- }
- },
- production: {
- src: ['test/browser/less/production/*.less'],
- options: {
- helpers: 'test/browser/runner-production-options.js',
- specs: 'test/browser/runner-production-spec.js',
- outfile: 'tmp/browser/test-runner-production.html'
- }
- },
- modifyVars: {
- src: ['test/browser/less/modify-vars/*.less'],
- options: {
- helpers: 'test/browser/runner-modify-vars-options.js',
- specs: 'test/browser/runner-modify-vars-spec.js',
- outfile: 'tmp/browser/test-runner-modify-vars.html'
- }
- },
- globalVars: {
- src: ['test/browser/less/global-vars/*.less'],
- options: {
- helpers: 'test/browser/runner-global-vars-options.js',
- specs: 'test/browser/runner-global-vars-spec.js',
- outfile: 'tmp/browser/test-runner-global-vars.html'
- }
- },
- postProcessor: {
- src: ['test/browser/less/postProcessor/*.less'],
- options: {
- helpers: 'test/browser/runner-postProcessor-options.js',
- specs: 'test/browser/runner-postProcessor.js',
- outfile: 'tmp/browser/test-postProcessor.html'
+ jasmine: {
+ options: {
+ // version: '2.0.0-rc2',
+ keepRunner: true,
+ host: 'http://localhost:8081/',
+ vendor: ['test/browser/common.js', 'test/browser/less.js'],
+ template: 'test/browser/test-runner-template.tmpl'
+ },
+ main: {
+ // src is used to build list of less files to compile
+ src: ['test/less/*.less', '!test/less/javascript.less', '!test/less/urls.less', '!test/less/empty.less'],
+ options: {
+ helpers: 'test/browser/runner-main-options.js',
+ specs: 'test/browser/runner-main-spec.js',
+ outfile: 'tmp/browser/test-runner-main.html'
+ }
+ },
+ legacy: {
+ src: ['test/less/legacy/*.less'],
+ options: {
+ helpers: 'test/browser/runner-legacy-options.js',
+ specs: 'test/browser/runner-legacy-spec.js',
+ outfile: 'tmp/browser/test-runner-legacy.html'
+ }
+ },
+ errors: {
+ src: ['test/less/errors/*.less', '!test/less/errors/javascript-error.less'],
+ options: {
+ timeout: 20000,
+ helpers: 'test/browser/runner-errors-options.js',
+ specs: 'test/browser/runner-errors-spec.js',
+ outfile: 'tmp/browser/test-runner-errors.html'
+ }
+ },
+ noJsErrors: {
+ src: ['test/less/no-js-errors/*.less'],
+ options: {
+ helpers: 'test/browser/runner-no-js-errors-options.js',
+ specs: 'test/browser/runner-no-js-errors-spec.js',
+ outfile: 'tmp/browser/test-runner-no-js-errors.html'
+ }
+ },
+ browser: {
+ src: ['test/browser/less/*.less'],
+ options: {
+ helpers: 'test/browser/runner-browser-options.js',
+ specs: 'test/browser/runner-browser-spec.js',
+ outfile: 'tmp/browser/test-runner-browser.html'
+ }
+ },
+ relativeUrls: {
+ src: ['test/browser/less/relative-urls/*.less'],
+ options: {
+ helpers: 'test/browser/runner-relative-urls-options.js',
+ specs: 'test/browser/runner-relative-urls-spec.js',
+ outfile: 'tmp/browser/test-runner-relative-urls.html'
+ }
+ },
+ rootpath: {
+ src: ['test/browser/less/rootpath/*.less'],
+ options: {
+ helpers: 'test/browser/runner-rootpath-options.js',
+ specs: 'test/browser/runner-rootpath-spec.js',
+ outfile: 'tmp/browser/test-runner-rootpath.html'
+ }
+ },
+ rootpathRelative: {
+ src: ['test/browser/less/rootpath-relative/*.less'],
+ options: {
+ helpers: 'test/browser/runner-rootpath-relative-options.js',
+ specs: 'test/browser/runner-rootpath-relative-spec.js',
+ outfile: 'tmp/browser/test-runner-rootpath-relative.html'
+ }
+ },
+ production: {
+ src: ['test/browser/less/production/*.less'],
+ options: {
+ helpers: 'test/browser/runner-production-options.js',
+ specs: 'test/browser/runner-production-spec.js',
+ outfile: 'tmp/browser/test-runner-production.html'
+ }
+ },
+ modifyVars: {
+ src: ['test/browser/less/modify-vars/*.less'],
+ options: {
+ helpers: 'test/browser/runner-modify-vars-options.js',
+ specs: 'test/browser/runner-modify-vars-spec.js',
+ outfile: 'tmp/browser/test-runner-modify-vars.html'
+ }
+ },
+ globalVars: {
+ src: ['test/browser/less/global-vars/*.less'],
+ options: {
+ helpers: 'test/browser/runner-global-vars-options.js',
+ specs: 'test/browser/runner-global-vars-spec.js',
+ outfile: 'tmp/browser/test-runner-global-vars.html'
+ }
+ },
+ postProcessor: {
+ src: ['test/browser/less/postProcessor/*.less'],
+ options: {
+ helpers: 'test/browser/runner-postProcessor-options.js',
+ specs: 'test/browser/runner-postProcessor.js',
+ outfile: 'tmp/browser/test-postProcessor.html'
+ }
+ }
+ },
+
+ // Clean the version of less built for the tests
+ clean: {
+ test: ['test/browser/less.js', 'tmp'],
+ "sourcemap-test": ['test/sourcemaps/*.css', 'test/sourcemaps/*.map']
}
- }
- },
+ });
+
+ // Load these plugins to provide the necessary tasks
+ require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
- // Clean the version of less built for the tests
- clean: {
- test: ['test/browser/less.js', 'tmp'],
- "sourcemap-test": ['test/sourcemaps/*.css', 'test/sourcemaps/*.map']
- }
- });
+ // Actually load this plugin's task(s).
+ grunt.loadTasks('build/tasks');
- // Load these plugins to provide the necessary tasks
- require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
+ // by default, run tests
+ grunt.registerTask('default', [
+ 'test'
+ ]);
- // Actually load this plugin's task(s).
- grunt.loadTasks('build/tasks');
+ grunt.registerTask('updateBowerJson', function () {
+ var bowerJson = require('./bower.json');
+ bowerJson.version = grunt.config('pkg.version');
+ fs.writeFileSync('./bower.json', JSON.stringify(bowerJson, null, 2));
+ });
- // by default, run tests
- grunt.registerTask('default', [
- 'test'
- ]);
+ // Release
+ grunt.registerTask('dist', [
+ 'browserify:browser',
+ 'concat:dist',
+ 'uglify:dist',
+ 'updateBowerJson'
+ ]);
- // Release
- grunt.registerTask('stable', [
- 'concat:stable',
- 'uglify:stable'
- ]);
+ // Release Rhino Version
+ grunt.registerTask('rhino', [
+ 'browserify:rhino',
+ 'concat:rhino',
+ 'concat:rhinolessc'
+ ]);
- // Release Rhino Version
- grunt.registerTask('rhino', [
- 'concat:rhino',
- 'concat:rhinolessc'
- ]);
+ // Create the browser version of less.js
+ grunt.registerTask('browsertest-lessjs', [
+ 'browserify:browser',
+ 'concat:browsertest'
+ ]);
- // Run all browser tests
- grunt.registerTask('browsertest', [
- 'browser',
- 'connect',
- 'jasmine'
- ]);
+ // Run all browser tests
+ grunt.registerTask('browsertest', [
+ 'browsertest-lessjs',
+ 'connect',
+ 'jasmine'
+ ]);
- // setup a web server to run the browser tests in a browser rather than phantom
- grunt.registerTask('browsertest-server', [
- 'shell:browsertest-server'
- ]);
+ // setup a web server to run the browser tests in a browser rather than phantom
+ grunt.registerTask('browsertest-server', [
+ 'browsertest-less',
+ 'shell:browsertest-server'
+ ]);
- // Create the browser version of less.js
- grunt.registerTask('browser', [
- 'concat:browsertest'
- ]);
+ // Run all tests
+ grunt.registerTask('test', [
+ 'clean',
+ 'jshint',
+ 'shell:test',
+ 'browsertest'
+ ]);
- // Run all tests
- grunt.registerTask('test', [
- 'clean',
- 'jshint',
- 'shell:test',
- 'browsertest'
- ]);
+ // generate a good test environment for testing sourcemaps
+ grunt.registerTask('sourcemap-test', [
+ 'clean:sourcemap-test',
+ 'shell:sourcemap-test'
+ ]);
- // generate a good test environment for testing sourcemaps
- grunt.registerTask('sourcemap-test', [
- 'clean:sourcemap-test',
- 'shell:sourcemap-test'
- ]);
+ // Run benchmark
+ grunt.registerTask('benchmark', [
+ 'shell:benchmark'
+ ]);
- // Readme.
- grunt.registerTask('readme', [
- 'concat:readme'
- ]);
-
- // Run benchmark
- grunt.registerTask('benchmark', [
- 'shell:benchmark'
- ]);
};
diff --cc bin/lessc
index 1fb0193,6842002..59defad
--- a/bin/lessc
+++ b/bin/lessc
@@@ -1,8 -1,7 +1,7 @@@
#!/usr/bin/env node
var path = require('path'),
- fs = require('../lib/less/fs'),
+ fs = require('../lib/less/environment/node/fs'),
- sys = require('util'),
os = require('os'),
mkdirp;
@@@ -348,14 -351,12 +350,14 @@@ var parseLessFile = function (e, data)
return;
} else if (options.depends) {
for(var file in parser.imports.files) {
- process.stdout.write(file + " ")
+ if (parser.imports.files.hasOwnProperty(file)) {
- sys.print(file + " ");
++ process.stdout.write(file + " ");
+ }
}
- sys.print("\n");
+ console.log("");
} else {
try {
- if (options.lint) { writeSourceMap = function() {} }
+ if (options.lint) { writeSourceMap = function() {}; }
var css = tree.toCSS({
silent: options.silent,
verbose: options.verbose,
@@@ -384,8 -385,8 +386,8 @@@
console.log('lessc: wrote ' + output);
}
} else {
- sys.print(css);
+ process.stdout.write(css);
- }
+ }
}
} catch (e) {
less.writeError(e, options);
diff --cc lib/less/environment/browser.js
index 28b26c0,0000000..30d2b5c
mode 100644,000000..100644
--- a/lib/less/environment/browser.js
+++ b/lib/less/environment/browser.js
@@@ -1,206 -1,0 +1,206 @@@
+/*global window, XMLHttpRequest */
+
+module.exports = function(less, isFileProtocol, log, logLevel) {
+
+var fileCache = {};
+
+//TODOS - move log somewhere. pathDiff and doing something similiar in node. use pathDiff in the other browser file for the initial load
+// isFileProtocol is global
+
+function getXMLHttpRequest() {
+ if (window.XMLHttpRequest && (window.location.protocol !== "file:" || !("ActiveXObject" in window))) {
+ return new XMLHttpRequest();
+ } else {
+ try {
+ /*global ActiveXObject */
+ return new ActiveXObject("Microsoft.XMLHTTP");
+ } catch (e) {
+ log("browser doesn't support AJAX.", logLevel.errors);
+ return null;
+ }
+ }
+}
+
+return {
+ // make generic but overriddable
+ warn: function warn(env, msg) {
+ console.warn(msg);
+ },
+ // make generic but overriddable
+ getPath: function getPath(env, filename) {
+ var j = filename.lastIndexOf('/');
+ if (j < 0) {
+ j = filename.lastIndexOf('\\');
+ }
+ if (j < 0) {
+ return "";
+ }
+ return filename.slice(0, j + 1);
+ },
+ // make generic but overriddable
+ isPathAbsolute: function isPathAbsolute(env, filename) {
- return /^(?:[a-z-]+:|\/|\\)/.test(filename);
++ return /^(?:[a-z-]+:|\/|\\)/i.test(filename);
+ },
+ alwaysMakePathsAbsolute: function alwaysMakePathsAbsolute() {
+ return true;
+ },
+ getCleanCSS: function () {
+ },
+ supportsDataURI: function() {
+ return false;
+ },
+ pathDiff: function pathDiff(url, baseUrl) {
+ // diff between two paths to create a relative path
+
+ var urlParts = this.extractUrlParts(url),
+ baseUrlParts = this.extractUrlParts(baseUrl),
+ i, max, urlDirectories, baseUrlDirectories, diff = "";
+ if (urlParts.hostPart !== baseUrlParts.hostPart) {
+ return "";
+ }
+ max = Math.max(baseUrlParts.directories.length, urlParts.directories.length);
+ for(i = 0; i < max; i++) {
+ if (baseUrlParts.directories[i] !== urlParts.directories[i]) { break; }
+ }
+ baseUrlDirectories = baseUrlParts.directories.slice(i);
+ urlDirectories = urlParts.directories.slice(i);
+ for(i = 0; i < baseUrlDirectories.length-1; i++) {
+ diff += "../";
+ }
+ for(i = 0; i < urlDirectories.length-1; i++) {
+ diff += urlDirectories[i] + "/";
+ }
+ return diff;
+ },
+ join: function join(basePath, laterPath) {
+ if (!basePath) {
+ return laterPath;
+ }
+ return this.extractUrlParts(laterPath, basePath).path;
+ },
+ // helper function, not part of API
+ extractUrlParts: function extractUrlParts(url, baseUrl) {
+ // urlParts[1] = protocol&hostname || /
+ // urlParts[2] = / if path relative to host base
+ // urlParts[3] = directories
+ // urlParts[4] = filename
+ // urlParts[5] = parameters
+
+ var urlPartsRegex = /^((?:[a-z-]+:)?\/+?(?:[^\/\?#]*\/)|([\/\\]))?((?:[^\/\\\?#]*[\/\\])*)([^\/\\\?#]*)([#\?].*)?$/i,
+ urlParts = url.match(urlPartsRegex),
+ returner = {}, directories = [], i, baseUrlParts;
+
+ if (!urlParts) {
+ throw new Error("Could not parse sheet href - '"+url+"'");
+ }
+
+ // Stylesheets in IE don't always return the full path
+ if (!urlParts[1] || urlParts[2]) {
+ baseUrlParts = baseUrl.match(urlPartsRegex);
+ if (!baseUrlParts) {
+ throw new Error("Could not parse page url - '"+baseUrl+"'");
+ }
+ urlParts[1] = urlParts[1] || baseUrlParts[1] || "";
+ if (!urlParts[2]) {
+ urlParts[3] = baseUrlParts[3] + urlParts[3];
+ }
+ }
+
+ if (urlParts[3]) {
+ directories = urlParts[3].replace(/\\/g, "/").split("/");
+
+ // extract out . before .. so .. doesn't absorb a non-directory
+ for(i = 0; i < directories.length; i++) {
+ if (directories[i] === ".") {
+ directories.splice(i, 1);
+ i -= 1;
+ }
+ }
+
+ for(i = 0; i < directories.length; i++) {
+ if (directories[i] === ".." && i > 0) {
+ directories.splice(i-1, 2);
+ i -= 2;
+ }
+ }
+ }
+
+ returner.hostPart = urlParts[1];
+ returner.directories = directories;
+ returner.path = urlParts[1] + directories.join("/");
+ returner.fileUrl = returner.path + (urlParts[4] || "");
+ returner.url = returner.fileUrl + (urlParts[5] || "");
+ return returner;
+ },
+ doXHR: function doXHR(url, type, callback, errback) {
+
+ var xhr = getXMLHttpRequest();
+ var async = isFileProtocol ? less.fileAsync : less.async;
+
+ if (typeof(xhr.overrideMimeType) === 'function') {
+ xhr.overrideMimeType('text/css');
+ }
+ log("XHR: Getting '" + url + "'", logLevel.debug);
+ xhr.open('GET', url, async);
+ xhr.setRequestHeader('Accept', type || 'text/x-less, text/css; q=0.9, */*; q=0.5');
+ xhr.send(null);
+
+ function handleResponse(xhr, callback, errback) {
+ if (xhr.status >= 200 && xhr.status < 300) {
+ callback(xhr.responseText,
+ xhr.getResponseHeader("Last-Modified"));
+ } else if (typeof(errback) === 'function') {
+ errback(xhr.status, url);
+ }
+ }
+
+ if (isFileProtocol && !less.fileAsync) {
+ if (xhr.status === 0 || (xhr.status >= 200 && xhr.status < 300)) {
+ callback(xhr.responseText);
+ } else {
+ errback(xhr.status, url);
+ }
+ } else if (async) {
+ xhr.onreadystatechange = function () {
+ if (xhr.readyState == 4) {
+ handleResponse(xhr, callback, errback);
+ }
+ };
+ } else {
+ handleResponse(xhr, callback, errback);
+ }
+ },
+ loadFile: function loadFile(env, filename, currentDirectory, callback) {
+ if (currentDirectory && !this.isPathAbsolute(env, filename)) {
+ filename = currentDirectory + filename;
+ }
+
+ // sheet may be set to the stylesheet for the initial load or a collection of properties including
+ // some env variables for imports
+ var hrefParts = this.extractUrlParts(filename, window.location.href);
+ var href = hrefParts.url;
+
+ if (env.useFileCache && fileCache[href]) {
+ try {
+ var lessText = fileCache[href];
+ callback(null, lessText, href, { lastModified: new Date() });
+ } catch (e) {
+ callback(e, null, href);
+ }
+ return;
+ }
+
+ this.doXHR(href, env.mime, function doXHRCallback(data, lastModified) {
+ // per file cache
+ fileCache[href] = data;
+
+ // Use remote copy (re-parse)
+ callback(null, data, href, { lastModified: lastModified });
+ }, function doXHRError(status, url) {
+ callback({ type: 'File', message: "'" + url + "' wasn't found (" + status + ")" }, null, href);
+ });
+
+ }
+};
+
+};
diff --cc lib/less/environment/node.js
index febae6b,0000000..884f6eb
mode 100644,000000..100644
--- a/lib/less/environment/node.js
+++ b/lib/less/environment/node.js
@@@ -1,221 -1,0 +1,221 @@@
+var path = require('path'),
+ url = require('url'),
+ request,
+ fs = require('./node/fs'),
+ isUrlRe = /^(?:https?:)?\/\//i;
+
+module.exports = {
+ warn: function(env, msg) {
+ console.warn(msg);
+ },
+ encodeBase64: function encodeBase64(env, str) {
+ return new Buffer(str).toString('base64');
+ },
+ supportsDataURI: function(env) {
+ return true;
+ },
+ mimeLookup: function (env, filename) {
+ return require('mime').lookup(filename);
+ },
+ charsetLookup: function (env, mime) {
+ return require('mime').charsets.lookup(mime);
+ },
+ readFileSync: function (filename) {
+ return require("fs").readFileSync(filename);
+ },
+ getCleanCSS: function() {
+ return require('clean-css');
+ },
+ getPath: function (env, filename) {
+ var j = filename.lastIndexOf('/');
+ if (j < 0) {
+ j = filename.lastIndexOf('\\');
+ }
+ if (j < 0) {
+ return "";
+ }
+ return filename.slice(0, j + 1);
+ },
+ isPathAbsolute: function(env, filename) {
- return (/^(?:[a-z-]+:|\/|\\)/).test(filename);
++ return (/^(?:[a-z-]+:|\/|\\)/i).test(filename);
+ },
+ getAbsolutePath: function getAbsolutePath(env, filename) {
+ return require('path').resolve(filename);
+ },
+ getSourceMapGenerator: function getSourceMapGenerator() {
+ return require("source-map").SourceMapGenerator;
+ },
+ alwaysMakePathsAbsolute: function alwaysMakePathsAbsolute() {
+ return false;
+ },
+ join: function join(basePath, laterPath) {
+ if (!basePath) {
+ return laterPath;
+ }
+ return basePath + laterPath;
+ },
+ pathDiff: function pathDiff(url, baseUrl) {
+ // diff between two paths to create a relative path
+
+ var urlParts = this.extractUrlParts(url),
+ baseUrlParts = this.extractUrlParts(baseUrl),
+ i, max, urlDirectories, baseUrlDirectories, diff = "";
+ if (urlParts.hostPart !== baseUrlParts.hostPart) {
+ return "";
+ }
+ max = Math.max(baseUrlParts.directories.length, urlParts.directories.length);
+ for(i = 0; i < max; i++) {
+ if (baseUrlParts.directories[i] !== urlParts.directories[i]) { break; }
+ }
+ baseUrlDirectories = baseUrlParts.directories.slice(i);
+ urlDirectories = urlParts.directories.slice(i);
+ for(i = 0; i < baseUrlDirectories.length-1; i++) {
+ diff += "../";
+ }
+ for(i = 0; i < urlDirectories.length-1; i++) {
+ diff += urlDirectories[i] + "/";
+ }
+ return diff;
+ },
+ // helper function, not part of API
+ extractUrlParts: function extractUrlParts(url, baseUrl) {
+ // urlParts[1] = protocol&hostname || /
+ // urlParts[2] = / if path relative to host base
+ // urlParts[3] = directories
+ // urlParts[4] = filename
+ // urlParts[5] = parameters
+
+ var urlPartsRegex = /^((?:[a-z-]+:)?\/+?(?:[^\/\?#]*\/)|([\/\\]))?((?:[^\/\\\?#]*[\/\\])*)([^\/\\\?#]*)([#\?].*)?$/i,
+ urlParts = url.match(urlPartsRegex),
+ returner = {}, directories = [], i, baseUrlParts;
+
+ if (!urlParts) {
+ throw new Error("Could not parse sheet href - '"+url+"'");
+ }
+
+ // Stylesheets in IE don't always return the full path
+ if (baseUrl && (!urlParts[1] || urlParts[2])) {
+ baseUrlParts = baseUrl.match(urlPartsRegex);
+ if (!baseUrlParts) {
+ throw new Error("Could not parse page url - '"+baseUrl+"'");
+ }
+ urlParts[1] = urlParts[1] || baseUrlParts[1] || "";
+ if (!urlParts[2]) {
+ urlParts[3] = baseUrlParts[3] + urlParts[3];
+ }
+ }
+
+ if (urlParts[3]) {
+ directories = urlParts[3].replace(/\\/g, "/").split("/");
+
+ // extract out . before .. so .. doesn't absorb a non-directory
+ for(i = 0; i < directories.length; i++) {
+ if (directories[i] === ".") {
+ directories.splice(i, 1);
+ i -= 1;
+ }
+ }
+
+ for(i = 0; i < directories.length; i++) {
+ if (directories[i] === ".." && i > 0) {
+ directories.splice(i-1, 2);
+ i -= 2;
+ }
+ }
+ }
+
+ returner.hostPart = urlParts[1];
+ returner.directories = directories;
+ returner.path = urlParts[1] + directories.join("/");
+ returner.fileUrl = returner.path + (urlParts[4] || "");
+ returner.url = returner.fileUrl + (urlParts[5] || "");
+ return returner;
+ },
+ loadFile: function(env, filename, currentDirectory, callback) {
+ var fullFilename,
+ data,
+ isUrl = isUrlRe.test( filename );
+
+ if (isUrl || isUrlRe.test(currentDirectory)) {
+ if (request === undefined) {
+ try { request = require('request'); }
+ catch(e) { request = null; }
+ }
+ if (!request) {
+ callback({ type: 'File', message: "optional dependency 'request' required to import over http(s)\n" });
+ return;
+ }
+
+ var urlStr = isUrl ? filename : url.resolve(currentDirectory, filename),
+ urlObj = url.parse(urlStr);
+
+ if (!urlObj.protocol) {
+ urlObj.protocol = "http";
+ urlStr = urlObj.format();
+ }
+
+ request.get({uri: urlStr, strictSSL: !env.insecure }, function (error, res, body) {
+ if (error) {
+ callback({ type: 'File', message: "resource '" + urlStr + "' gave this Error:\n "+ error +"\n" });
+ }
+ if (res && res.statusCode === 404) {
+ callback({ type: 'File', message: "resource '" + urlStr + "' was not found\n" });
+ return;
+ }
+ if (!body) {
+ this.warn( env, 'Warning: Empty body (HTTP '+ res.statusCode + ') returned by "' + urlStr +'"');
+ }
+ fullFilename = urlStr;
+ callback(null, body, fullFilename);
+ });
+ } else {
+
+ var paths = [currentDirectory];
+ if (env.paths) paths.push.apply(paths, env.paths);
+ if (paths.indexOf('.') === -1) paths.push('.');
+
+ if (env.syncImport) {
+ for (var i = 0; i < paths.length; i++) {
+ try {
+ fullFilename = path.join(paths[i], filename);
+ fs.statSync(fullFilename);
+ break;
+ } catch (e) {
+ fullFilename = null;
+ }
+ }
+
+ if (!fullFilename) {
+ callback({ type: 'File', message: "'" + filename + "' wasn't found" });
+ return;
+ }
+
+ data = fs.readFileSync(fullFilename, 'utf-8');
+ callback(null, data, fullFilename);
+ } else {
+ (function tryPathIndex(i) {
+ if (i < paths.length) {
+ fullFilename = path.join(paths[i], filename);
+ fs.stat(fullFilename, function (err) {
+ if (err) {
+ tryPathIndex(i + 1);
+ } else {
+ fs.readFile(fullFilename, 'utf-8', function(e, data) {
+ if (e) { callback(e); }
+
+ // do processing in the next tick to allow
+ // file handling to dispose
+ process.nextTick(function() {
+ callback(null, data, fullFilename);
+ });
+ });
+ }
+ });
+ } else {
+ callback({ type: 'File', message: "'" + filename + "' wasn't found" });
+ }
+ }(0));
+ }
+ }
+ }
+};
diff --cc lib/less/functions.js
index d950bdd,f99264c..e55f6af
--- a/lib/less/functions.js
+++ b/lib/less/functions.js
@@@ -418,11 -422,18 +418,18 @@@ var functions =
filePath = mimetype;
}
+ var fragmentStart = filePath.indexOf('#');
+ var fragment = '';
+ if (fragmentStart!==-1) {
+ fragment = filePath.slice(fragmentStart);
+ filePath = filePath.slice(0, fragmentStart);
+ }
+
if (this.env.isPathRelative(filePath)) {
if (this.currentFileInfo.relativeUrls) {
- filePath = path.join(this.currentFileInfo.currentDirectory, filePath);
+ filePath = less.environment.join(this.currentFileInfo.currentDirectory, filePath);
} else {
- filePath = path.join(this.currentFileInfo.entryPath, filePath);
+ filePath = less.environment.join(this.currentFileInfo.entryPath, filePath);
}
}
diff --cc lib/less/tree/anonymous.js
index 16b08a2,4584061..711579f
--- a/lib/less/tree/anonymous.js
+++ b/lib/less/tree/anonymous.js
@@@ -1,15 -1,16 +1,16 @@@
-(function (tree) {
+module.exports = function (tree) {
- var Anonymous = function (value, index, currentFileInfo, mapLines) {
-tree.Anonymous = function (value, index, currentFileInfo, mapLines, rulesetLike) {
++var Anonymous = function (value, index, currentFileInfo, mapLines, rulesetLike) {
this.value = value;
this.index = index;
this.mapLines = mapLines;
this.currentFileInfo = currentFileInfo;
+ this.rulesetLike = (typeof rulesetLike === 'undefined')? false : rulesetLike;
};
-tree.Anonymous.prototype = {
+Anonymous.prototype = {
type: "Anonymous",
- eval: function () {
- return new tree.Anonymous(this.value, this.index, this.currentFileInfo, this.mapLines, this.rulesetLike);
+ eval: function () {
- return new Anonymous(this.value, this.index, this.currentFileInfo, this.mapLines);
++ return new Anonymous(this.value, this.index, this.currentFileInfo, this.mapLines, this.rulesetLike);
},
compare: function (x) {
if (!x.toCSS) {
@@@ -22,9 -23,12 +23,12 @@@
if (left === right) {
return 0;
}
-
+
return left < right ? -1 : 1;
},
+ isRulesetLike: function() {
+ return this.rulesetLike;
+ },
genCSS: function (env, output) {
output.add(this.value, this.currentFileInfo, this.index, this.mapLines);
},
diff --cc lib/less/tree/combinator.js
index 0fd4dd8,0000000..0e34baf
mode 100644,000000..100644
--- a/lib/less/tree/combinator.js
+++ b/lib/less/tree/combinator.js
@@@ -1,40 -1,0 +1,24 @@@
+module.exports = function (tree) {
+
+var Combinator = function (value) {
+ if (value === ' ') {
+ this.value = ' ';
+ } else {
+ this.value = value ? value.trim() : "";
+ }
+};
+Combinator.prototype = {
+ type: "Combinator",
- _outputMap: {
- '' : '',
- ' ' : ' ',
- ':' : ' :',
- '+' : ' + ',
- '~' : ' ~ ',
- '>' : ' > ',
- '|' : '|',
- '^' : ' ^ ',
- '^^' : ' ^^ '
- },
- _outputMapCompressed: {
- '' : '',
- ' ' : ' ',
- ':' : ' :',
- '+' : '+',
- '~' : '~',
- '>' : '>',
- '|' : '|',
- '^' : '^',
- '^^' : '^^'
++ _noSpaceCombinators: {
++ '': true,
++ ' ': true,
++ '|': true
+ },
+ genCSS: function (env, output) {
- output.add((env.compress ? this._outputMapCompressed : this._outputMap)[this.value]);
++ var spaceOrEmpty = (env.compress || this._noSpaceCombinators[this.value]) ? '' : ' ';
++ output.add(spaceOrEmpty + this.value + spaceOrEmpty);
+ },
+ toCSS: tree.toCSS
+};
+return Combinator;
+};
diff --cc lib/less/tree/element.js
index 925b4b9,055cce8..3b5a6a7
--- a/lib/less/tree/element.js
+++ b/lib/less/tree/element.js
@@@ -41,5 -41,52 +41,4 @@@ Element.prototype =
}
}
};
-
-tree.Attribute = function (key, op, value) {
- this.key = key;
- this.op = op;
- this.value = value;
-};
-tree.Attribute.prototype = {
- type: "Attribute",
- eval: function (env) {
- return new(tree.Attribute)(this.key.eval ? this.key.eval(env) : this.key,
- this.op, (this.value && this.value.eval) ? this.value.eval(env) : this.value);
- },
- genCSS: function (env, output) {
- output.add(this.toCSS(env));
- },
- toCSS: function (env) {
- var value = this.key.toCSS ? this.key.toCSS(env) : this.key;
-
- if (this.op) {
- value += this.op;
- value += (this.value.toCSS ? this.value.toCSS(env) : this.value);
- }
-
- return '[' + value + ']';
- }
-};
-
-tree.Combinator = function (value) {
- if (value === ' ') {
- this.value = ' ';
- } else {
- this.value = value ? value.trim() : "";
- }
-};
-tree.Combinator.prototype = {
- type: "Combinator",
- _noSpaceCombinators: {
- '': true,
- ' ': true,
- '|': true
- },
- genCSS: function (env, output) {
- var spaceOrEmpty = (env.compress || this._noSpaceCombinators[this.value]) ? '' : ' ';
- output.add(spaceOrEmpty + this.value + spaceOrEmpty);
- },
- toCSS: tree.toCSS
-};
-
-})(require('../tree'));
+return Element;
- };
diff --cc lib/less/tree/import.js
index 4d4c45b,0d00a64..2042e2e
--- a/lib/less/tree/import.js
+++ b/lib/less/tree/import.js
@@@ -97,16 -97,16 +97,16 @@@ Import.prototype =
this.skip = this.skip();
}
if (this.skip) {
- return [];
+ return [];
}
}
-
+
if (this.options.inline) {
//todo needs to reference css file not import
- var contents = new(tree.Anonymous)(this.root, 0, {filename: this.importedFilename}, true);
+ var contents = new(tree.Anonymous)(this.root, 0, {filename: this.importedFilename}, true, true);
return this.features ? new(tree.Media)([contents], this.features.value) : [contents];
} else if (this.css) {
- var newImport = new(tree.Import)(this.evalPath(env), features, this.options, this.index);
+ var newImport = new(Import)(this.evalPath(env), features, this.options, this.index);
if (!newImport.css && this.error) {
throw this.error;
}
diff --cc package.json
index 749353d,a36f420..01e4f67
--- a/package.json
+++ b/package.json
@@@ -40,13 -40,12 +40,13 @@@
"test": "grunt test"
},
"optionalDependencies": {
- "graceful-fs": "~2.0.3",
+ "graceful-fs": "~3.0.2",
"mime": "~1.2.11",
- "request": "~2.34.0",
- "mkdirp": "~0.3.5",
- "clean-css": "2.1.x",
+ "request": "~2.40.0",
+ "mkdirp": "~0.5.0",
+ "clean-css": "2.2.x",
- "source-map": "0.1.x"
+ "source-map": "0.1.x",
+ "promise": "~5.0.0"
},
"devDependencies": {
"diff": "~1.0",
diff --cc test/browser/common.js
index 6e2bb38,6e2bb38..21ec8a3
--- a/test/browser/common.js
+++ b/test/browser/common.js
@@@ -71,7 -71,7 +71,7 @@@ var testSheet = function(sheet)
//TODO: do it cleaner - the same way as in css
function extractId(href) {
-- return href.replace(/^[a-z-]+:\/+?[^\/]+/, '') // Remove protocol & domain
++ return href.replace(/^[a-z-]+:\/+?[^\/]+/i, '') // Remove protocol & domain
.replace(/^\//, '') // Remove root /
.replace(/\.[a-zA-Z]+$/, '') // Remove simple extension
.replace(/[^\.\w-]+/g, '-') // Replace illegal characters
@@@ -198,4 -198,4 +198,4 @@@ var loadFile = function(href)
}, 3000);
}
--})();
++})();
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/less.js.git
More information about the Pkg-javascript-commits
mailing list