Skip to content

Commit

Permalink
Checking if CSS declarations exist
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Holland committed Aug 4, 2014
1 parent f9cb3f1 commit 6fb4734
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions tasks/cachebust.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,21 @@ module.exports = function(grunt) {
var cssObj = css.parse(data);

// Loop through each stylesheet rules
cssObj.stylesheet.rules.forEach(function(rule) {
if(cssObj.stylesheet) {
cssObj.stylesheet.rules.forEach(function(rule) {

// Loop through all declarations
rule.declarations.forEach(function(declaration) {
// Loop through all declarations
if(rule.declarations) {
rule.declarations.forEach(function(declaration) {

// Check if it has a background property, and if so, checkt that it contains a URL
if((/background/).test(declaration.property) && (/url/).test(declaration.value)) {
paths.push(declaration.value.match(/url\(["|']?(.*?)['|"]?\)/)[1]);
// Check if it has a background property, and if so, checkt that it contains a URL
if((/background/).test(declaration.property) && (/url/).test(declaration.value)) {
paths.push(declaration.value.match(/url\(["|']?(.*?)['|"]?\)/)[1]);
}
});
}
});
});
}
} else {
// Add any conditional statements or assets in comments to the DOM
var assets = '';
Expand Down

0 comments on commit 6fb4734

Please sign in to comment.