Skip to content

Commit

Permalink
Ignore !important CSS tag
Browse files Browse the repository at this point in the history
  • Loading branch information
odrobnik authored and Yifan Zhang committed Mar 25, 2013
1 parent c22b7ec commit 70c7d48
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Core/Source/DTCSSStylesheet.m
Expand Up @@ -412,6 +412,22 @@ - (void)_addStyleRule:(NSString *)rule withSelector:(NSString*)selectors
NSString *cleanSelector = [selector stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

NSMutableDictionary *ruleDictionary = [[rule dictionaryOfCSSStyles] mutableCopy];

// remove !important, we're ignoring these
for (NSString *oneKey in [ruleDictionary allKeys])
{
NSString *value = [ruleDictionary objectForKey:oneKey];

NSRange rangeOfImportant = [value rangeOfString:@"!important" options:NSCaseInsensitiveSearch];

if (rangeOfImportant.location != NSNotFound)
{
value = [value stringByReplacingCharactersInRange:rangeOfImportant withString:@""];
value = [value stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

[ruleDictionary setObject:value forKey:oneKey];
}
}

// need to uncompress because otherwise we might get shorthands and non-shorthands together
[self _uncompressShorthands:ruleDictionary];
Expand Down

0 comments on commit 70c7d48

Please sign in to comment.