Permalink
Browse files

Calling [htmlWriter pushElementAttribute:@"class" value:@"foo"] autom…

…atically pushes that onto the class stack instead.
  • Loading branch information...
1 parent 6bc0b29 commit e96c6c83611a6818815d2d62eeac61e556ad8fb5 @mikeabdullah mikeabdullah committed Jul 28, 2010
Showing with 14 additions and 1 deletion.
  1. +1 −0 KSHTMLWriter.h
  2. +13 −1 KSHTMLWriter.m
View
@@ -35,6 +35,7 @@
#pragma mark CSS Class Name
// Class names are accumulated and written automatically as an attribute of the next element started
+// You can also push a class name using -pushElementAttribute:value: if attribute is 'class'
- (void)pushElementClassName:(NSString *)className;
- (NSString *)elementClassName;
View
@@ -69,6 +69,18 @@ - (NSString *)elementClassName;
return result;
}
+- (void)pushElementAttribute:(NSString *)attribute value:(NSString *)value;
+{
+ if ([attribute isEqualToString:@"class"])
+ {
+ [self pushElementClassName:value];
+ }
+ else
+ {
+ [super pushElementAttribute:attribute value:value];
+ }
+}
+
- (NSDictionary *)elementAttributes;
{
id result = [super elementAttributes];
@@ -322,7 +334,7 @@ - (void)startElement:(NSString *)elementName writeInline:(BOOL)writeInline; // f
if (class)
{
[_classNames removeAllObjects];
- [self pushElementAttribute:@"class" value:class];
+ [super pushElementAttribute:@"class" value:class];
}
[super startElement:elementName writeInline:writeInline];

0 comments on commit e96c6c8

Please sign in to comment.