Add convenience methods to create Class & ID Attribute Selectors
http://www.w3.org/TR/css3-selectors/#class-html http://www.w3.org/TR/css3-selectors/#id-selectors
This commit is contained in:
@@ -26,6 +26,9 @@ typedef NS_ENUM(NSUInteger, CSSAttributeSelectorType)
|
||||
@property (nonatomic, copy) NSString *name;
|
||||
@property (nonatomic, copy) NSString *value;
|
||||
|
||||
+ (instancetype)selectorForClass:(NSString *)className;
|
||||
+ (instancetype)selectorForId:(NSString *)elementId;
|
||||
|
||||
- (instancetype)initWithType:(CSSAttributeSelectorType)type
|
||||
attributeName:(NSString *)name
|
||||
attrbiuteValue:(NSString *)value;
|
||||
|
||||
@@ -20,6 +20,16 @@
|
||||
|
||||
@implementation CSSAttributeSelector
|
||||
|
||||
+ (instancetype)selectorForClass:(NSString *)className
|
||||
{
|
||||
return [[self alloc] initWithType:CSSAttributeSelectorIncludes attributeName:@"class" attrbiuteValue:className];
|
||||
}
|
||||
|
||||
+ (instancetype)selectorForId:(NSString *)elementId
|
||||
{
|
||||
return [[self alloc] initWithType:CSSAttributeSelectorExactMatch attributeName:@"id" attrbiuteValue:elementId];
|
||||
}
|
||||
|
||||
- (instancetype)initWithType:(CSSAttributeSelectorType)type
|
||||
attributeName:(NSString *)name
|
||||
attrbiuteValue:(NSString *)value
|
||||
|
||||
Reference in New Issue
Block a user