Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

less.js has no method 'toCSS' on watch

I am using less.js (version 1.2.1) on localhost (on Windows), and when I use less.watch() in console, I keep getting this error:

less.js:9 Uncaught TypeError: Object #<HTMLLinkElement> has no method 'toCSS'

I searched for an answer to solve this, but no luck. Anyway on how to fix this error? The less.watch() does work, but it also is slow and every second I get that error.

Anyway to fix this?

There is really nothing in the html, here is how I set up less though. Am I doing it wrong?

<link rel="stylesheet/less" type="text/css" href="css/styles.less">

<script src="js/less.js" type="text/javascript"></script>

Firebug Console:

b.toCSS is not a function
[Break On This Error]   

b && r(b.toCSS(), d, e.lastModified)
like image 894
nowayyy Avatar asked Oct 09 '22 18:10

nowayyy


1 Answers

Dev version is at https://github.com/cloudhead/less.js/blob/master/dist/less-1.2.1.js

The relevant section is:

if (less.env === 'development') {
    less.optimization = 0;

    if (/!watch/.test(location.hash)) {
        less.watch();
    }
    less.watchTimer = setInterval(function () {
        if (less.watchMode) {
            loadStyleSheets(function (e, root, _, sheet, env) {
                if (root) {
                    createCSS(root.toCSS(), sheet, env.lastModified);
                }
            });
        }
    }, less.poll);
} else {
    less.optimization = 3;
}

In the section:

if (root) {
    createCSS(root.toCSS(), sheet, env.lastModified);
}

Change:

if (root) {

to:

if (root && sheet) {

then re-minify (if desired) and use the new file.

like image 179
pete Avatar answered Oct 13 '22 12:10

pete