Skip to content
Browse files

Split out -startJavascriptElementWithSrc:

  • Loading branch information...
1 parent 27cf398 commit 1ca811e69630814b4d2b9098e072663d70e120ec @mikeabdullah mikeabdullah committed
Showing with 11 additions and 8 deletions.
  1. +1 −0 KSHTMLWriter.h
  2. +10 −8 KSHTMLWriter.m
View
1 KSHTMLWriter.h
@@ -89,6 +89,7 @@
- (void)writeJavascriptWithSrc:(NSString *)src;
- (void)writeJavascript:(NSString *)script useCDATA:(BOOL)useCDATA;
+- (void)startJavascriptElementWithSrc:(NSString *)src; // src may be nil
// Like -startCDATA and -endCDATA, but wrapped in a javascript comment so don't risk tripping up a browser's interpreter
- (void)startJavascriptCDATA;
View
18 KSHTMLWriter.m
@@ -155,19 +155,13 @@ - (void)writeJavascriptWithSrc:(NSString *)src;
{
NSParameterAssert(src);
- [self openTag:@"script"];
- [self writeAttribute:@"type" value:@"text/javascript"]; // in theory, HTML5 pages could omit this
- [self writeAttribute:@"src" value:src];
- [self didStartElement];
-
+ [self startJavascriptElementWithSrc:src];
[self endElement];
}
- (void)writeJavascript:(NSString *)script useCDATA:(BOOL)useCDATA;
{
- [self openTag:@"script"];
- [self writeAttribute:@"type" value:@"text/javascript"]; // in theory, HTML5 pages could omit this
- [self didStartElement];
+ [self startJavascriptElementWithSrc:nil];
if (useCDATA) [self startJavascriptCDATA];
@@ -180,6 +174,14 @@ - (void)writeJavascript:(NSString *)script useCDATA:(BOOL)useCDATA;
[self endElement];
}
+- (void)startJavascriptElementWithSrc:(NSString *)src; // src may be nil
+{
+ [self openTag:@"script"];
+ [self writeAttribute:@"type" value:@"text/javascript"]; // in theory, HTML5 pages could omit this
+ if (src) [self writeAttribute:@"src" value:src];
+ [self didStartElement];
+}
+
- (void)startJavascriptCDATA;
{
[self writeString:@"\n/* "];

0 comments on commit 1ca811e

Please sign in to comment.
Something went wrong with that request. Please try again.