Skip to content

Commit

Permalink
Sorry to keep changing this, but -pushElementAttribute: really is too…
Browse files Browse the repository at this point in the history
… wordy. Shortening to -pushAttribute:
  • Loading branch information
Mike authored and Mike committed Sep 2, 2010
1 parent 1ac43a1 commit b12f4c9
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion DOM/KSHTMLWriter+DOM.m
Expand Up @@ -76,7 +76,7 @@ - (void)startElement:(NSString *)elementName withDOMElement:(DOMElement *)elemen
for (index = 0; index < [attributes length]; index++)
{
DOMAttr *anAttribute = (DOMAttr *)[attributes item:index];
[self pushElementAttribute:[anAttribute name] value:[anAttribute value]];
[self pushAttribute:[anAttribute name] value:[anAttribute value]];
}
}

Expand Down
2 changes: 1 addition & 1 deletion KSHTMLWriter.h
Expand Up @@ -35,7 +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'
// You can also push a class name using -pushAttribute:value: if attribute is 'class'
- (void)pushElementClassName:(NSString *)className;
- (NSString *)elementClassName;

Expand Down
46 changes: 23 additions & 23 deletions KSHTMLWriter.m
Expand Up @@ -69,15 +69,15 @@ - (NSString *)elementClassName;
return result;
}

- (void)pushElementAttribute:(NSString *)attribute value:(NSString *)value;
- (void)pushAttribute:(NSString *)attribute value:(NSString *)value;
{
if ([attribute isEqualToString:@"class"])
{
[self pushElementClassName:value];
}
else
{
[super pushElementAttribute:attribute value:value];
[super pushAttribute:attribute value:value];
}
}

Expand Down Expand Up @@ -121,8 +121,8 @@ - (void)startElement:(NSString *)tagName className:(NSString *)className;

- (void)startElement:(NSString *)tagName idName:(NSString *)idName className:(NSString *)className;
{
if (idName) [self pushElementAttribute:@"id" value:idName];
if (className) [self pushElementAttribute:@"class" value:className];
if (idName) [self pushAttribute:@"id" value:idName];
if (className) [self pushAttribute:@"class" value:className];

[self startElement:tagName];
}
Expand All @@ -139,10 +139,10 @@ - (void)writeLineBreak;

- (void)startAnchorElementWithHref:(NSString *)href title:(NSString *)titleString target:(NSString *)targetString rel:(NSString *)relString;
{
if (href) [self pushElementAttribute:@"href" value:href];
if (targetString) [self pushElementAttribute:@"target" value:targetString];
if (titleString) [self pushElementAttribute:@"title" value:titleString];
if (relString) [self pushElementAttribute:@"rel" value:relString];
if (href) [self pushAttribute:@"href" value:href];
if (targetString) [self pushAttribute:@"target" value:targetString];
if (titleString) [self pushAttribute:@"title" value:titleString];
if (relString) [self pushAttribute:@"rel" value:relString];

[self startElement:@"a"];
}
Expand All @@ -152,10 +152,10 @@ - (void)writeImageWithSrc:(NSString *)src
width:(NSString *)width
height:(NSString *)height;
{
[self pushElementAttribute:@"src" value:src];
[self pushElementAttribute:@"alt" value:alt];
if (width) [self pushElementAttribute:@"width" value:width];
if (height) [self pushElementAttribute:@"height" value:height];
[self pushAttribute:@"src" value:src];
[self pushAttribute:@"alt" value:alt];
if (width) [self pushAttribute:@"width" value:width];
if (height) [self pushAttribute:@"height" value:height];

[self startElement:@"img"];
[self endElement];
Expand All @@ -171,11 +171,11 @@ - (void)writeLinkWithHref:(NSString *)href
title:(NSString *)title
media:(NSString *)media;
{
if (rel) [self pushElementAttribute:@"rel" value:rel];
if (type) [self pushElementAttribute:@"type" value:type];
[self pushElementAttribute:@"href" value:href];
if (title) [self pushElementAttribute:@"title" value:title];
if (media) [self pushElementAttribute:@"media" value:media];
if (rel) [self pushAttribute:@"rel" value:rel];
if (type) [self pushAttribute:@"type" value:type];
[self pushAttribute:@"href" value:href];
if (title) [self pushAttribute:@"title" value:title];
if (media) [self pushAttribute:@"media" value:media];

[self startElement:@"link"];
[self endElement];
Expand Down Expand Up @@ -211,8 +211,8 @@ - (void)writeJavascript:(NSString *)script useCDATA:(BOOL)useCDATA;

- (void)startJavascriptElementWithSrc:(NSString *)src; // src may be nil
{
[self pushElementAttribute:@"type" value:@"text/javascript"]; // in theory, HTML5 pages could omit this
if (src) [self pushElementAttribute:@"src" value:src];
[self pushAttribute:@"type" value:@"text/javascript"]; // in theory, HTML5 pages could omit this
if (src) [self pushAttribute:@"src" value:src];

[self startElement:@"script"];

Expand Down Expand Up @@ -242,8 +242,8 @@ - (void)endJavascriptCDATA;

- (void)writeParamElementWithName:(NSString *)name value:(NSString *)value;
{
if (name) [self pushElementAttribute:@"name" value:name];
if (value) [self pushElementAttribute:@"value" value:value];
if (name) [self pushAttribute:@"name" value:name];
if (value) [self pushAttribute:@"value" value:value];
[self startElement:@"param"];
[self endElement];
}
Expand All @@ -259,7 +259,7 @@ - (void)writeStyleElementWithCSSString:(NSString *)css;

- (void)startStyleElementWithType:(NSString *)type;
{
if (type) [self pushElementAttribute:@"type" value:type];
if (type) [self pushAttribute:@"type" value:type];
[self startElement:@"style"];
}

Expand Down Expand Up @@ -343,7 +343,7 @@ - (void)startElement:(NSString *)elementName writeInline:(BOOL)writeInline; // f
if (class)
{
[_classNames removeAllObjects];
[super pushElementAttribute:@"class" value:class];
[super pushAttribute:@"class" value:class];
}

[super startElement:elementName writeInline:writeInline];
Expand Down
2 changes: 1 addition & 1 deletion KSXMLWriter.h
Expand Up @@ -77,7 +77,7 @@
* - More efficient than building up a temporary dictionary object
* - Can sneak extra attributes in when using a convenience method (e.g. for HTML)
*/
- (void)pushElementAttribute:(NSString *)attribute value:(NSString *)value;
- (void)pushAttribute:(NSString *)attribute value:(NSString *)value;
- (NSDictionary *)elementAttributes;


Expand Down
4 changes: 2 additions & 2 deletions KSXMLWriter.m
Expand Up @@ -186,7 +186,7 @@ - (void)startElement:(NSString *)elementName attributes:(NSDictionary *)attribut
for (NSString *aName in attributes)
{
NSString *aValue = [attributes objectForKey:aName];
[self pushElementAttribute:aName value:aValue];
[self pushAttribute:aName value:aValue];
}

[self startElement:elementName];
Expand Down Expand Up @@ -222,7 +222,7 @@ - (void)endElement;
}
}

- (void)pushElementAttribute:(NSString *)attribute value:(NSString *)value; // call before -startElement:
- (void)pushAttribute:(NSString *)attribute value:(NSString *)value; // call before -startElement:
{
NSParameterAssert(value);
[_attributes addObject:attribute];
Expand Down

0 comments on commit b12f4c9

Please sign in to comment.