initial warnings

This commit is contained in:
Luke Page
2014-11-28 19:48:16 +00:00
parent 94a6501ade
commit 0f29c4f094

View File

@@ -1,5 +1,6 @@
var tree = require("../tree"),
Visitor = require("./visitor");
Visitor = require("./visitor"),
logger = require("../logger");
/*jshint loopfunc:true */
@@ -98,7 +99,20 @@ ProcessExtendsVisitor.prototype = {
if (!extendFinder.foundExtends) { return root; }
root.allExtends = root.allExtends.concat(this.doExtendChaining(root.allExtends, root.allExtends));
this.allExtendsStack = [root.allExtends];
return this._visitor.visit(root);
var newRoot = this._visitor.visit(root);
this.checkExtendsForNonMatched(root.allExtends);
return newRoot;
},
checkExtendsForNonMatched: function(extendList) {
extendList.filter(function(extend) {
return !extend.hasFoundMatches;
}).forEach(function(extend) {
var selector = "_unknown_";
try {
selector = extend.selector.toCSS({});
}catch(_){}
logger.warn("extend '"+selector+"' has no matches");
});
},
doExtendChaining: function (extendsList, extendsListTarget, iterationCount) {
//
@@ -135,6 +149,8 @@ ProcessExtendsVisitor.prototype = {
if (matches.length) {
extend.hasFoundMatches = true;
// we found a match, so for each self selector..
extend.selfSelectors.forEach(function(selfSelector) {
@@ -218,6 +234,7 @@ ProcessExtendsVisitor.prototype = {
matches = this.findMatch(allExtends[extendIndex], selectorPath);
if (matches.length) {
allExtends[extendIndex].hasFoundMatches = true;
allExtends[extendIndex].selfSelectors.forEach(function(selfSelector) {
selectorsToAdd.push(extendVisitor.extendSelector(matches, selectorPath, selfSelector));
@@ -403,7 +420,9 @@ ProcessExtendsVisitor.prototype = {
this.allExtendsStack.push(newAllExtends);
},
visitMediaOut: function (mediaNode) {
this.allExtendsStack.length = this.allExtendsStack.length - 1;
var lastIndex = this.allExtendsStack.length - 1;
this.checkExtendsForNonMatched(this.allExtendsStack[lastIndex]);
this.allExtendsStack.length = lastIndex;
},
visitDirective: function (directiveNode, visitArgs) {
var newAllExtends = directiveNode.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length-1]);
@@ -411,7 +430,9 @@ ProcessExtendsVisitor.prototype = {
this.allExtendsStack.push(newAllExtends);
},
visitDirectiveOut: function (directiveNode) {
this.allExtendsStack.length = this.allExtendsStack.length - 1;
var lastIndex = this.allExtendsStack.length - 1;
this.checkExtendsForNonMatched(this.allExtendsStack[lastIndex]);
this.allExtendsStack.length = lastIndex;
}
};