Skip to content
Browse files

If linking to a script, generally should specify charset

  • Loading branch information...
1 parent 3530727 commit 1d5ee5fa0291085a646678b32629ec8443d84bad @mikeabdullah mikeabdullah committed Apr 1, 2011
Showing with 4 additions and 4 deletions.
  1. +1 −1 KSHTMLWriter.h
  2. +3 −3 KSHTMLWriter.m
View
2 KSHTMLWriter.h
@@ -126,7 +126,7 @@ extern NSString *KSHTMLWriterDocTypeHTML_5;
#pragma mark Scripts
-- (void)writeJavascriptWithSrc:(NSString *)src;
+- (void)writeJavascriptWithSrc:(NSString *)src charset:(NSString *)charset;
- (void)writeJavascript:(NSString *)script useCDATA:(BOOL)useCDATA;
- (void)startJavascriptElementWithSrc:(NSString *)src; // src may be nil
View
6 KSHTMLWriter.m
@@ -246,10 +246,11 @@ - (void)writeLinkToStylesheet:(NSString *)href
#pragma mark Scripts
-- (void)writeJavascriptWithSrc:(NSString *)src;
+- (void)writeJavascriptWithSrc:(NSString *)src charset:(NSString *)charset;
{
NSParameterAssert(src);
+ if (charset) [self pushAttribute:@"charset" value:charset];
[self startJavascriptElementWithSrc:src];
[self endElement];
}
@@ -277,9 +278,8 @@ - (void)startJavascriptElementWithSrc:(NSString *)src; // src may be nil
if (src)
{
[self pushAttribute:@"src" value:src];
- [self pushAttribute:@"charset" value:@"UTF-8"]; // ensure that remotely load source is UTF-8
}
-
+
[self startElement:@"script"];
// Embedded scripts should start on their own line for clarity

0 comments on commit 1d5ee5f

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