6 Commits

Author SHA1 Message Date
Iskandar Abudiab 118cb41971 Bump version to 4.2.0 2021-04-29 20:11:41 +02:00
Iskandar Abudiab 3d9f2007ee Update tokenizer and parser logic to pass latest test suite 2021-04-29 20:07:05 +02:00
Iskandar Abudiab e79f96e217 Update html5lib-tests to latest commit as of 2021.04.28 2021-04-29 18:15:14 +02:00
Iskandar Abudiab 3333274cfb Use HTMLElement's designated initialiser in tests
Fixes #43
2021-04-29 18:14:15 +02:00
Iskandar Abudiab 26ee9e683f Update CI badge 2021-04-29 17:08:45 +02:00
Iskandar Abudiab 9e45ac5fa1 Update badges in Readme 2021-04-28 18:22:47 +02:00
13 changed files with 171 additions and 166 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
module: HTMLKit
module_version: 4.1.0
module_version: 4.2.0
author: Iskandar Abudiab
author_url: https://twitter.com/iabudiab
github_url: https://github.com/iabudiab/HTMLKit
+6
View File
@@ -1,5 +1,11 @@
# Change Log
## [4.2.0](https://github.com/iabudiab/HTMLKit/releases/tag/4.1.0)
- Fix test compilation under Xcode 12.5 (issue #43)
- Updated HTML5Lib-Tests submodule (082a4be)
- Updated parser and tokenizer for latest spec changes to pass test suite
## [4.1.0](https://github.com/iabudiab/HTMLKit/releases/tag/4.1.0)
- Updated project for Xcode 12.5
+1 -1
View File
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "HTMLKit"
s.version = "4.1.0"
s.version = "4.2.0"
s.summary = "HTMLKit, an Objective-C framework for your everyday HTML needs."
s.license = "MIT"
s.homepage = "https://github.com/iabudiab/HTMLKit"
+10 -10
View File
@@ -2217,7 +2217,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.9;
MACOSX_DEPLOYMENT_TARGET = 10.15;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
};
@@ -2265,7 +2265,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.9;
MACOSX_DEPLOYMENT_TARGET = 10.15;
SDKROOT = macosx;
};
name = Release;
@@ -2291,7 +2291,7 @@
INSTALL_PATH = "@rpath";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MARKETING_VERSION = 4.1.0;
MARKETING_VERSION = 4.2.0;
PRODUCT_BUNDLE_IDENTIFIER = dev.iabudiab.HTMLKit;
PRODUCT_NAME = HTMLKit;
TVOS_DEPLOYMENT_TARGET = 12.0;
@@ -2321,7 +2321,7 @@
INSTALL_PATH = "@rpath";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MACOSX_DEPLOYMENT_TARGET = 10.11;
MARKETING_VERSION = 4.1.0;
MARKETING_VERSION = 4.2.0;
PRODUCT_BUNDLE_IDENTIFIER = dev.iabudiab.HTMLKit;
PRODUCT_NAME = HTMLKit;
TVOS_DEPLOYMENT_TARGET = 12.0;
@@ -2402,7 +2402,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 4.1.0;
MARKETING_VERSION = 4.2.0;
MTL_ENABLE_DEBUG_INFO = YES;
PRODUCT_BUNDLE_IDENTIFIER = dev.iabudiab.HTMLKit;
PRODUCT_MODULE_NAME = HTMLKit;
@@ -2441,7 +2441,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 4.1.0;
MARKETING_VERSION = 4.2.0;
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = dev.iabudiab.HTMLKit;
PRODUCT_MODULE_NAME = HTMLKit;
@@ -2482,7 +2482,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 4.1.0;
MARKETING_VERSION = 4.2.0;
MTL_ENABLE_DEBUG_INFO = YES;
PRODUCT_BUNDLE_IDENTIFIER = dev.iabudiab.HTMLKit;
PRODUCT_NAME = HTMLKit;
@@ -2521,7 +2521,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 4.1.0;
MARKETING_VERSION = 4.2.0;
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = dev.iabudiab.HTMLKit;
PRODUCT_NAME = HTMLKit;
@@ -2603,7 +2603,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 4.1.0;
MARKETING_VERSION = 4.2.0;
MTL_ENABLE_DEBUG_INFO = YES;
PRODUCT_BUNDLE_IDENTIFIER = dev.iabudiab.HTMLKit;
PRODUCT_NAME = HTMLKit;
@@ -2643,7 +2643,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 4.1.0;
MARKETING_VERSION = 4.2.0;
MTL_ENABLE_DEBUG_INFO = NO;
PRODUCT_BUNDLE_IDENTIFIER = dev.iabudiab.HTMLKit;
PRODUCT_NAME = HTMLKit;
+4 -5
View File
@@ -1,14 +1,13 @@
# HTMLKit
![HTMLKit Logo](https://raw.githubusercontent.com/iabudiab/HTMLKit/master/HTMLKit.png)
![HTMLKit Logo](https://raw.githubusercontent.com/iabudiab/HTMLKit/main/HTMLKit.png)
An Objective-C framework for your everyday HTML needs.
[![Build Status](https://img.shields.io/travis/iabudiab/HTMLKit/develop.svg?style=flat)](https://travis-ci.org/iabudiab/HTMLKit)
[![codecov](https://codecov.io/gh/iabudiab/HTMLKit/branch/develop/graph/badge.svg)](https://codecov.io/gh/iabudiab/HTMLKit)
[![HTMLKit CI](https://github.com/iabudiab/HTMLKit/actions/workflows/ci.yml/badge.svg)](https://github.com/iabudiab/HTMLKit/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/iabudiab/HTMLKit/branch/main/graph/badge.svg)](https://codecov.io/gh/iabudiab/HTMLKit)
[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/HTMLKit.svg?style=flat)](https://cocoapods.org/pods/HTMLKit)
[![CocoaDocs](https://img.shields.io/cocoapods/metrics/doc-percent/HTMLKit.svg?style=flat)](http://cocoadocs.org/docsets/HTMLKit)
[![Platform](https://img.shields.io/cocoapods/p/HTMLKit.svg?style=flat)](http://cocoadocs.org/docsets/HTMLKit)
[![License MIT](https://img.shields.io/badge/license-MIT-4481C7.svg?style=flat)](https://opensource.org/licenses/MIT)
@@ -77,7 +76,7 @@ To add `HTMLKit` as a dependency into your project using CocoaPods just add the
```ruby
target 'MyTarget' do
pod 'HTMLKit', '~> 4.1'
pod 'HTMLKit', '~> 4.2'
end
```
+15 -19
View File
@@ -1308,7 +1308,7 @@
_framesetOkFlag = NO;
} else if ([tagName isEqualToString:@"a"]) {
HTMLElement *element = ^ HTMLElement * {
for (HTMLElement *element in self->_listOfActiveFormattingElements.reverseObjectEnumerator) {
for (HTMLElement *element in self->_listOfActiveFormattingElements.reverseObjectEnumerator) {
if ([element isEqual:[HTMLMarker marker]]) return nil;
if ([element.tagName isEqualToString:@"a"]) {
return element;
@@ -2513,13 +2513,13 @@
[characters enumerateSubstringsInRange:NSMakeRange(0, characters.length)
options:NSStringEnumerationByComposedCharacterSequences
usingBlock:^(NSString *substring, NSRange substringRange, NSRange enclosingRange, BOOL *stop) {
if ([substring isEqualToString:@"\uFFFD"]) {
[self emitParseError:@"Unexpected Character (0x0000) in foreign content"];
} else if (!substring.htmlkit_isHTMLWhitespaceString) {
self->_framesetOkFlag = NO;
}
[self insertCharacters:substring];
}];
if ([substring isEqualToString:@"\uFFFD"]) {
[self emitParseError:@"Unexpected Character (0x0000) in foreign content"];
} else if (!substring.htmlkit_isHTMLWhitespaceString) {
self->_framesetOkFlag = NO;
}
[self insertCharacters:substring];
}];
return;
}
@@ -2541,23 +2541,19 @@
}
[self insertForeignElementForToken:token.asTagToken inNamespace:self.adjustedCurrentNode.htmlNamespace];
if (token.asTagToken.selfClosing) {
[self->_stackOfOpenElements popCurrentNode];
[self->_stackOfOpenElements popCurrentNode];
}
};
void (^ matchedCase)(void) = ^ {
[self emitParseError:@"Unexpected start tag <%@> in foreign content", token.asTagToken.tagName];
if (self->_fragmentParsingAlgorithm) {
anythingElse();
} else {
[self->_stackOfOpenElements popCurrentNode];
while (!IsNodeMathMLTextIntegrationPoint(self.currentNode) &&
!IsNodeHTMLIntegrationPoint(self.currentNode) &&
self.currentNode.htmlNamespace != HTMLNamespaceHTML) {
[self->_stackOfOpenElements popCurrentNode];
}
[self reprocessToken:token];
while (!IsNodeMathMLTextIntegrationPoint(self.currentNode) &&
!IsNodeHTMLIntegrationPoint(self.currentNode) &&
self.currentNode.htmlNamespace != HTMLNamespaceHTML) {
[self->_stackOfOpenElements popCurrentNode];
}
[self processToken:token byApplyingRulesForInsertionMode:HTMLInsertionModeInBody];
};
if ([token.asTagToken.tagName isEqualToAny:@"b", @"big", @"blockquote", @"body", @"br",
+1
View File
@@ -2413,6 +2413,7 @@
usingComparator:^ NSComparisonResult (id obj1, id obj2) { return [obj1 compare:obj2]; }];
if (searchIndex >= entities.count || ![[entities objectAtIndex:searchIndex] hasPrefix:name]) {
[name setString:[name substringToIndex:name.length -1]];
break;
}
+98 -95
View File
@@ -29,64 +29,66 @@ NS_INLINE void AdjustSVGAttributes(HTMLTagToken *token)
return;
}
NSDictionary *replacements = @{@"attributename": @"attributeName",
@"attributetype": @"attributeType",
@"basefrequency": @"baseFrequency",
@"baseprofile": @"baseProfile",
@"calcmode": @"calcMode",
@"clippathunits": @"clipPathUnits",
@"diffuseconstant": @"diffuseConstant",
@"edgemode": @"edgeMode",
@"filterunits": @"filterUnits",
@"glyphref": @"glyphRef",
@"gradienttransform": @"gradientTransform",
@"gradientunits": @"gradientUnits",
@"kernelmatrix": @"kernelMatrix",
@"kernelunitlength": @"kernelUnitLength",
@"keypoints": @"keyPoints",
@"keysplines": @"keySplines",
@"keytimes": @"keyTimes",
@"lengthadjust": @"lengthAdjust",
@"limitingconeangle": @"limitingConeAngle",
@"markerheight": @"markerHeight",
@"markerunits": @"markerUnits",
@"markerwidth": @"markerWidth",
@"maskcontentunits": @"maskContentUnits",
@"maskunits": @"maskUnits",
@"numoctaves": @"numOctaves",
@"pathlength": @"pathLength",
@"patterncontentunits": @"patternContentUnits",
@"patterntransform": @"patternTransform",
@"patternunits": @"patternUnits",
@"pointsatx": @"pointsAtX",
@"pointsaty": @"pointsAtY",
@"pointsatz": @"pointsAtZ",
@"preservealpha": @"preserveAlpha",
@"preserveaspectratio": @"preserveAspectRatio",
@"primitiveunits": @"primitiveUnits",
@"refx": @"refX",
@"refy": @"refY",
@"repeatcount": @"repeatCount",
@"repeatdur": @"repeatDur",
@"requiredextensions": @"requiredExtensions",
@"requiredfeatures": @"requiredFeatures",
@"specularconstant": @"specularConstant",
@"specularexponent": @"specularExponent",
@"spreadmethod": @"spreadMethod",
@"startoffset": @"startOffset",
@"stddeviation": @"stdDeviation",
@"stitchtiles": @"stitchTiles",
@"surfacescale": @"surfaceScale",
@"systemlanguage": @"systemLanguage",
@"tablevalues": @"tableValues",
@"targetx": @"targetX",
@"targety": @"targetY",
@"textlength": @"textLength",
@"viewbox": @"viewBox",
@"viewtarget": @"viewTarget",
@"xchannelselector": @"xChannelSelector",
@"ychannelselector": @"yChannelSelector",
@"zoomandpan": @"zoomAndPan"};
NSDictionary *replacements = @{
@"attributename": @"attributeName",
@"attributetype": @"attributeType",
@"basefrequency": @"baseFrequency",
@"baseprofile": @"baseProfile",
@"calcmode": @"calcMode",
@"clippathunits": @"clipPathUnits",
@"diffuseconstant": @"diffuseConstant",
@"edgemode": @"edgeMode",
@"filterunits": @"filterUnits",
@"glyphref": @"glyphRef",
@"gradienttransform": @"gradientTransform",
@"gradientunits": @"gradientUnits",
@"kernelmatrix": @"kernelMatrix",
@"kernelunitlength": @"kernelUnitLength",
@"keypoints": @"keyPoints",
@"keysplines": @"keySplines",
@"keytimes": @"keyTimes",
@"lengthadjust": @"lengthAdjust",
@"limitingconeangle": @"limitingConeAngle",
@"markerheight": @"markerHeight",
@"markerunits": @"markerUnits",
@"markerwidth": @"markerWidth",
@"maskcontentunits": @"maskContentUnits",
@"maskunits": @"maskUnits",
@"numoctaves": @"numOctaves",
@"pathlength": @"pathLength",
@"patterncontentunits": @"patternContentUnits",
@"patterntransform": @"patternTransform",
@"patternunits": @"patternUnits",
@"pointsatx": @"pointsAtX",
@"pointsaty": @"pointsAtY",
@"pointsatz": @"pointsAtZ",
@"preservealpha": @"preserveAlpha",
@"preserveaspectratio": @"preserveAspectRatio",
@"primitiveunits": @"primitiveUnits",
@"refx": @"refX",
@"refy": @"refY",
@"repeatcount": @"repeatCount",
@"repeatdur": @"repeatDur",
@"requiredextensions": @"requiredExtensions",
@"requiredfeatures": @"requiredFeatures",
@"specularconstant": @"specularConstant",
@"specularexponent": @"specularExponent",
@"spreadmethod": @"spreadMethod",
@"startoffset": @"startOffset",
@"stddeviation": @"stdDeviation",
@"stitchtiles": @"stitchTiles",
@"surfacescale": @"surfaceScale",
@"systemlanguage": @"systemLanguage",
@"tablevalues": @"tableValues",
@"targetx": @"targetX",
@"targety": @"targetY",
@"textlength": @"textLength",
@"viewbox": @"viewBox",
@"viewtarget": @"viewTarget",
@"xchannelselector": @"xChannelSelector",
@"ychannelselector": @"yChannelSelector",
@"zoomandpan": @"zoomAndPan"
};
HTMLOrderedDictionary *adjusted = [HTMLOrderedDictionary new];
for (id key in token.attributes) {
@@ -99,43 +101,44 @@ NS_INLINE void AdjustSVGAttributes(HTMLTagToken *token)
NS_INLINE void AdjustSVGNameCase(HTMLTagToken *token)
{
NSDictionary *replacements = @{
@"altglyph": @"altGlyph",
@"altglyphdef": @"altGlyphDef",
@"altglyphitem": @"altGlyphItem",
@"animatecolor": @"animateColor",
@"animatemotion": @"animateMotion",
@"animatetransform": @"animateTransform",
@"clippath": @"clipPath",
@"feblend": @"feBlend",
@"fecolormatrix": @"feColorMatrix",
@"fecomponenttransfer": @"feComponentTransfer",
@"fecomposite": @"feComposite",
@"feconvolvematrix": @"feConvolveMatrix",
@"fediffuselighting": @"feDiffuseLighting",
@"fedisplacementmap": @"feDisplacementMap",
@"fedistantlight": @"feDistantLight",
@"fedropshadow": @"feDropShadow",
@"feflood": @"feFlood",
@"fefunca": @"feFuncA",
@"fefuncb": @"feFuncB",
@"fefuncg": @"feFuncG",
@"fefuncr": @"feFuncR",
@"fegaussianblur": @"feGaussianBlur",
@"feimage": @"feImage",
@"femerge": @"feMerge",
@"femergenode": @"feMergeNode",
@"femorphology": @"feMorphology",
@"feoffset": @"feOffset",
@"fepointlight": @"fePointLight",
@"fespecularlighting": @"feSpecularLighting",
@"fespotlight": @"feSpotLight",
@"fetile": @"feTile",
@"feturbulence": @"feTurbulence",
@"foreignobject": @"foreignObject",
@"glyphref": @"glyphRef",
@"lineargradient": @"linearGradient",
@"radialgradient": @"radialGradient",
@"textpath": @"textPath"};
@"altglyph": @"altGlyph",
@"altglyphdef": @"altGlyphDef",
@"altglyphitem": @"altGlyphItem",
@"animatecolor": @"animateColor",
@"animatemotion": @"animateMotion",
@"animatetransform": @"animateTransform",
@"clippath": @"clipPath",
@"feblend": @"feBlend",
@"fecolormatrix": @"feColorMatrix",
@"fecomponenttransfer": @"feComponentTransfer",
@"fecomposite": @"feComposite",
@"feconvolvematrix": @"feConvolveMatrix",
@"fediffuselighting": @"feDiffuseLighting",
@"fedisplacementmap": @"feDisplacementMap",
@"fedistantlight": @"feDistantLight",
@"fedropshadow": @"feDropShadow",
@"feflood": @"feFlood",
@"fefunca": @"feFuncA",
@"fefuncb": @"feFuncB",
@"fefuncg": @"feFuncG",
@"fefuncr": @"feFuncR",
@"fegaussianblur": @"feGaussianBlur",
@"feimage": @"feImage",
@"femerge": @"feMerge",
@"femergenode": @"feMergeNode",
@"femorphology": @"feMorphology",
@"feoffset": @"feOffset",
@"fepointlight": @"fePointLight",
@"fespecularlighting": @"feSpecularLighting",
@"fespotlight": @"feSpotLight",
@"fetile": @"feTile",
@"feturbulence": @"feTurbulence",
@"foreignobject": @"foreignObject",
@"glyphref": @"glyphRef",
@"lineargradient": @"linearGradient",
@"radialgradient": @"radialGradient",
@"textpath": @"textPath"
};
NSString *replacement = replacements[token.tagName] ?: token.tagName;
token.tagName = replacement;
+1 -1
View File
@@ -51,7 +51,7 @@
[_cases addObject:_currentCase];
}
- (void)testCase:(XCTestCase *)testCase didFailWithDescription:(NSString *)description inFile:(NSString *)filePath atLine:(NSUInteger)lineNumber
- (void)testCase:(XCTestCase *)testCase didRecordIssue:(XCTIssue *)issue
{
_currentCase[@"status"] = @"Failed";
}
@@ -28,7 +28,7 @@ extern uint64_t dispatch_benchmark(size_t count, void (^block)(void));
parent = [HTMLDocumentFragment new];
XCTAssertNoThrow([parent appendNode:element]);
parent = [HTMLElement new];
parent = [[HTMLElement alloc] initWithTagName:@"div"];
XCTAssertNoThrow([parent appendNode:element]);
parent = [HTMLTemplate new];
@@ -54,7 +54,7 @@ extern uint64_t dispatch_benchmark(size_t count, void (^block)(void));
parent = [HTMLDocumentFragment new];
XCTAssertNoThrow([parent insertNode:element beforeChildNode:nil]);
parent = [HTMLElement new];
parent = [[HTMLElement alloc] initWithTagName:@"div"];
XCTAssertNoThrow([parent insertNode:element beforeChildNode:nil]);
parent = [HTMLTemplate new];
@@ -115,9 +115,9 @@ extern uint64_t dispatch_benchmark(size_t count, void (^block)(void));
XCTAssertNoThrow([document appendNode:[HTMLDocumentFragment new]]);
XCTAssertNoThrow([document appendNode:[HTMLDocumentType new]]);
XCTAssertNoThrow([document appendNode:[HTMLElement new]]);
XCTAssertNoThrow([document appendNode:[[HTMLElement alloc] initWithTagName:@"div"]]);
HTMLElement *element = [HTMLElement new];
HTMLElement *element = [[HTMLElement alloc] initWithTagName:@"div"];
XCTAssertNoThrow([element appendNode:[HTMLTemplate new]]);
XCTAssertNoThrow([element appendNode:[HTMLComment new]]);
@@ -132,7 +132,7 @@ extern uint64_t dispatch_benchmark(size_t count, void (^block)(void));
XCTAssertThrows([[HTMLDocumentFragment new] appendNode:doctype]);
XCTAssertThrows([[HTMLDocumentType new] appendNode:doctype]);
XCTAssertThrows([[HTMLElement new] appendNode:doctype]);
XCTAssertThrows([[[HTMLElement alloc] initWithTagName:@"div"] appendNode:doctype]);
XCTAssertThrows([[HTMLTemplate new] appendNode:doctype]);
XCTAssertThrows([[HTMLComment new] appendNode:doctype]);
XCTAssertThrows([[HTMLText new] appendNode:doctype]);
@@ -148,7 +148,7 @@ extern uint64_t dispatch_benchmark(size_t count, void (^block)(void));
XCTAssertThrows([[HTMLText new] appendNode:text]);
XCTAssertNoThrow([[HTMLDocumentFragment new] appendNode:text]);
XCTAssertNoThrow([[HTMLElement new] appendNode:text]);
XCTAssertNoThrow([[[HTMLElement alloc] initWithTagName:@"div"] appendNode:text]);
XCTAssertNoThrow([[HTMLTemplate new] appendNode:text]);
}
@@ -172,8 +172,8 @@ extern uint64_t dispatch_benchmark(size_t count, void (^block)(void));
* Fragment has more than one Element child
*/
reset();
[fragment appendNode:[HTMLElement new]];
[fragment appendNode:[HTMLElement new]];
[fragment appendNode:[[HTMLElement alloc] initWithTagName:@"div"]];
[fragment appendNode:[[HTMLElement alloc] initWithTagName:@"div"]];
XCTAssertThrows([document appendNode:fragment]);
@@ -182,8 +182,8 @@ extern uint64_t dispatch_benchmark(size_t count, void (^block)(void));
* Document has an Element child
*/
reset();
[fragment appendNode:[HTMLElement new]];
[document appendNode:[HTMLElement new]];
[fragment appendNode:[[HTMLElement alloc] initWithTagName:@"div"]];
[document appendNode:[[HTMLElement alloc] initWithTagName:@"div"]];
XCTAssertThrows([document appendNode:fragment]);
/**
@@ -192,7 +192,7 @@ extern uint64_t dispatch_benchmark(size_t count, void (^block)(void));
*/
reset();
HTMLDocumentType *doctype = [HTMLDocumentType new];
[fragment appendNode:[HTMLElement new]];
[fragment appendNode:[[HTMLElement alloc] initWithTagName:@"div"]];
[document appendNode:doctype];
XCTAssertThrows([document insertNode:fragment beforeChildNode:doctype]);
@@ -202,7 +202,7 @@ extern uint64_t dispatch_benchmark(size_t count, void (^block)(void));
*/
reset();
HTMLComment *doctypePreviousSibling = [HTMLComment new];
[fragment appendNode:[HTMLElement new]];
[fragment appendNode:[[HTMLElement alloc] initWithTagName:@"div"]];
[document appendNode:doctypePreviousSibling];
[document appendNode:doctype];
XCTAssertThrows([document insertNode:fragment beforeChildNode:doctypePreviousSibling]);
@@ -211,7 +211,7 @@ extern uint64_t dispatch_benchmark(size_t count, void (^block)(void));
- (void)testValidElementInsertionIntoDocument
{
HTMLDocument *document = [HTMLDocument new];
HTMLElement *element = [HTMLElement new];
HTMLElement *element = [[HTMLElement alloc] initWithTagName:@"div"];
void (^ reset)(void) = ^ {
[element removeAllChildNodes];
@@ -221,7 +221,7 @@ extern uint64_t dispatch_benchmark(size_t count, void (^block)(void));
/**
* Document has an Element child
*/
[document appendNode:[HTMLElement new]];
[document appendNode:[[HTMLElement alloc] initWithTagName:@"div"]];
XCTAssertThrows([document appendNode:element]);
/**
@@ -262,7 +262,7 @@ extern uint64_t dispatch_benchmark(size_t count, void (^block)(void));
*/
reset();
HTMLComment *secondChild = [HTMLComment new];
[document appendNode:[HTMLElement new]];
[document appendNode:[[HTMLElement alloc] initWithTagName:@"div"]];
[document appendNode:secondChild];
XCTAssertThrows([document insertNode:doctype beforeChildNode:secondChild]);
@@ -270,7 +270,7 @@ extern uint64_t dispatch_benchmark(size_t count, void (^block)(void));
* Document has an Element child
*/
reset();
[document appendNode:[HTMLElement new]];
[document appendNode:[[HTMLElement alloc] initWithTagName:@"div"]];
XCTAssertThrows([document appendNode:doctype]);
}
@@ -296,8 +296,8 @@ extern uint64_t dispatch_benchmark(size_t count, void (^block)(void));
* Replacement Fragment has more than one Element child
*/
reset();
[replacement appendNode:[HTMLElement new]];
[replacement appendNode:[HTMLElement new]];
[replacement appendNode:[[HTMLElement alloc] initWithTagName:@"div"]];
[replacement appendNode:[[HTMLElement alloc] initWithTagName:@"div"]];
XCTAssertThrows([document replaceChildNode:child withNode:replacement]);
/**
@@ -305,8 +305,8 @@ extern uint64_t dispatch_benchmark(size_t count, void (^block)(void));
* Document has an Element child that is not the Replacement
*/
reset();
[replacement appendNode:[HTMLElement new]];
[document appendNode:[HTMLElement new]];
[replacement appendNode:[[HTMLElement alloc] initWithTagName:@"div"]];
[document appendNode:[[HTMLElement alloc] initWithTagName:@"div"]];
XCTAssertThrows([document replaceChildNode:child withNode:replacement]);
/**
@@ -315,7 +315,7 @@ extern uint64_t dispatch_benchmark(size_t count, void (^block)(void));
*/
reset();
HTMLDocumentType *doctype = [HTMLDocumentType new];
[replacement appendNode:[HTMLElement new]];
[replacement appendNode:[[HTMLElement alloc] initWithTagName:@"div"]];
[document appendNode:doctype];
XCTAssertThrows([document replaceChildNode:child withNode:replacement]);
}
@@ -324,7 +324,7 @@ extern uint64_t dispatch_benchmark(size_t count, void (^block)(void));
{
HTMLDocument *document = [HTMLDocument new];
HTMLComment *child = [HTMLComment new];
HTMLElement *replacement = [HTMLElement new];
HTMLElement *replacement = [[HTMLElement alloc] initWithTagName:@"div"];
void (^ reset)(void) = ^ {
[replacement removeAllChildNodes];
@@ -335,7 +335,7 @@ extern uint64_t dispatch_benchmark(size_t count, void (^block)(void));
/**
* Docment has an Element child that is not replacement
*/
[document appendNode:[HTMLElement new]];
[document appendNode:[[HTMLElement alloc] initWithTagName:@"div"]];
XCTAssertThrows([document replaceChildNode:child withNode:replacement]);
/**
@@ -369,7 +369,7 @@ extern uint64_t dispatch_benchmark(size_t count, void (^block)(void));
* An Element is preceding the child node
*/
reset();
[document insertNode:[HTMLElement new] beforeChildNode:child];
[document insertNode:[[HTMLElement alloc] initWithTagName:@"div"] beforeChildNode:child];
XCTAssertThrows([document replaceChildNode:child withNode:replacement]);
}
+8 -8
View File
@@ -53,8 +53,8 @@
XCTAssertEqual(element.childNodesCount, 1);
XCTAssertEqual(element.firstChild, comment);
HTMLElement *firstElement = [HTMLElement new];
HTMLElement *secondElement = [HTMLElement new];
HTMLElement *firstElement = [[HTMLElement alloc] initWithTagName:@"div"];
HTMLElement *secondElement = [[HTMLElement alloc] initWithTagName:@"div"];
NSArray *nodes = @[firstElement, secondElement];
[element appendNodes:nodes];
@@ -76,8 +76,8 @@
XCTAssertEqual(element.childNodesCount, 2);
XCTAssertEqual(element.firstChild, comment);
HTMLElement *firstElement = [HTMLElement new];
HTMLElement *secondElement = [HTMLElement new];
HTMLElement *firstElement = [[HTMLElement alloc] initWithTagName:@"div"];
HTMLElement *secondElement = [[HTMLElement alloc] initWithTagName:@"div"];
NSArray *nodes = @[firstElement, secondElement];
[element prependNodes:nodes];
@@ -94,8 +94,8 @@
[element appendNode:comment];
HTMLDocumentFragment *fragment = [HTMLDocumentFragment new];
HTMLElement *firstChild = [HTMLElement new];
HTMLElement *secondChild = [HTMLElement new];
HTMLElement *firstChild = [[HTMLElement alloc] initWithTagName:@"div"];
HTMLElement *secondChild = [[HTMLElement alloc] initWithTagName:@"div"];
[fragment appendNode:firstChild];
[fragment appendNode:secondChild];
@@ -494,7 +494,7 @@
XCTAssertTrue([paragraph compareDocumentPositionWithNode:paragraph] == HTMLDocumentPositionEquivalent);
HTMLElement *element = [HTMLElement new];
HTMLElement *element = [[HTMLElement alloc] initWithTagName:@"div"];
XCTAssertTrue([paragraph compareDocumentPositionWithNode:element] == HTMLDocumentPositionPreceding);
XCTAssertTrue([paragraph compareDocumentPositionWithNode:image] == HTMLDocumentPositionPreceding);
@@ -556,7 +556,7 @@
#pragma mark - Bug Fixes
- (void)testBugFix_Issue_20 {
HTMLElement *element = [HTMLElement new];
HTMLElement *element = [[HTMLElement alloc] initWithTagName:@"div"];
element.elementId = @"originalId";
HTMLElement *clone = [element cloneNodeDeep:YES];
+1 -1
View File
@@ -103,7 +103,7 @@
{
HTMLRange *range = [[HTMLRange alloc] initWithDocument:_document];
XCTAssertThrows([range setStartNode:[HTMLElement new] startOffset:0], @"Cannot set boundary to a node outside of the range's document");
XCTAssertThrows([range setStartNode:[[HTMLElement alloc] initWithTagName:@"div"] startOffset:0], @"Cannot set boundary to a node outside of the range's document");
XCTAssertThrows([range setStartNode:[HTMLDocumentType new] startOffset:0], @"DOCTYPE as range boundary is invalid");
XCTAssertThrows([range setStartNode:_firstText startOffset:_firstText.length + 1], @"Offset is outside the boundary node");