forked from veritech/CSSApply
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCSSSelector.h
48 lines (38 loc) · 1.65 KB
/
CSSSelector.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
// CSSSelector.h
// CSSSample
//
// Created by Sam Stewart on 7/16/11.
// Copyright 2011 Float:Right Ltd. All rights reserved.
//
/**
This class represents a CSS selector but only the last component or "slug". We discard all the levels (e.g. "ul ul li")
and just use the ending selector. This allows us to parse more appropriate information such as css class name, css id tag, etc.
*/
#import <Foundation/Foundation.h>
@interface CSSSelector : NSObject {
NSString *selector;
NSString *cssID;
// css class name (like div, ul, li, etc)
NSString *className;
// custom classes we defined (.ourclass,.customclass, ect)
NSMutableArray *classes;
}
- (id)initWithSelectorStr:(NSString*)selector;
- (id)initWithClassName:(NSString*)aClassName classNames:(NSSet*)aClassNames classID:(NSString*)aCssID;
/** Returns the components of the the selector (including the slug).
* The components which are separated by spaces (mainly descendant selectors).
*/
- (NSArray*)selectorComponents;
/** Checks to see if we partially/fully match the specified selector. Sort of a fuzzy matcher.*/
- (BOOL)doesMatchIntoSelector:(CSSSelector*)selector;
/** Convenience method to break long string (with mul sub selectors) into multiple small sub selectors.*/
+ (NSArray*)subSelectorsFromString:(NSString*)main_selector;
/** The classes which are applied to use.*/
@property (nonatomic, readonly) NSMutableArray *classes;
@property (nonatomic, readonly) NSString *cssID;
@property (nonatomic, readonly) NSString *className;
@property (nonatomic, readonly) NSString *selector;
//@property (nonatomic, readonly) NSString *
@property (readonly) NSInteger score;
@end