Skip to content

Commit

Permalink
Merge branch 'release/2.0.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
iabudiab committed Feb 26, 2017
2 parents 963a2b9 + fb60759 commit b5470a6
Show file tree
Hide file tree
Showing 39 changed files with 120 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .jazzy.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module: HTMLKit
module_version: 2.0.1
module_version: 2.0.2
author: Iskandar Abudiab
author_url: https://twitter.com/iabudiab
github_url: https://github.com/iabudiab/HTMLKit
Expand Down
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# Change Log

## [2.0.1](https://github.com/iabudiab/HTMLKit/releases/tag/2.0.0)
## [2.0.2](https://github.com/iabudiab/HTMLKit/releases/tag/2.0.2)

Released on 2017.02.26

### Fixed
- Retain cycles in `HTMLNodeIterator` (issue #4)
- Retain cycles in `HTMLRange` (issue #5)
- The layout of `HTMLKit` tests module for Swift Package Manager


## [2.0.1](https://github.com/iabudiab/HTMLKit/releases/tag/2.0.1)

Released on 2017.02.20

Expand Down
2 changes: 1 addition & 1 deletion HTMLKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "HTMLKit"
s.version = "2.0.1"
s.version = "2.0.2"
s.summary = "HTMLKit, an Objective-C framework for your everyday HTML needs."
s.license = "MIT"
s.homepage = "https://github.com/iabudiab/HTMLKit"
Expand Down
90 changes: 44 additions & 46 deletions HTMLKit.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import PackageDescription

let package = Package(
name: "HTMLKit"
name: "HTMLKit",
exclude: ["Tests/Resources", "Tests/css-tests", "Tests/html5lib-tests"]
)
8 changes: 4 additions & 4 deletions Sources/HTMLDocument.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
@interface HTMLDocument ()
{
HTMLDocument *_inertTemplateDocument;
NSMutableArray *_nodeIterators;
NSMutableArray *_ranges;
NSHashTable *_nodeIterators;
NSHashTable *_ranges;
}
@property (nonatomic, assign) HTMLDocumentReadyState readyState;
@end
Expand All @@ -41,8 +41,8 @@ - (instancetype)init
self = [super initWithName:@"#document" type:HTMLNodeDocument];
if (self) {
_readyState = HTMLDocumentLoading;
_nodeIterators = [NSMutableArray new];
_ranges = [NSMutableArray new];
_nodeIterators = [[NSHashTable alloc] initWithOptions:NSHashTableWeakMemory capacity:10];
_ranges = [[NSHashTable alloc] initWithOptions:NSHashTableWeakMemory capacity:10];
}
return self;
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/HTMLKit-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>2.0.1</string>
<string>2.0.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ @implementation HTMLKitParserPerformance
- (void)testParserPerformance
{
NSString *path = [[NSBundle bundleForClass:self.class] resourcePath];
path = [path stringByAppendingPathComponent:@"Fixtures"];
path = [path stringByAppendingPathComponent:@"HTML Standard.html"];

NSString *string = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
@interface HTMLKitTestUtil : NSObject

+ (NSInvocation *)addTestToClass:(Class)cls withName:(NSString *)name block:(id)block;
+ (id)ivarForInstacne:(id)instance name:(NSString *)name;

@end
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@ + (NSInvocation *)addTestToClass:(Class)cls withName:(NSString *)name block:(id)
return invocation;
}

+ (id)ivarForInstacne:(id)instance name:(NSString *)name
{
Ivar ivar = class_getInstanceVariable([instance class], [name UTF8String]);
return object_getIvar(instance, ivar);
}

@end
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ @implementation HTMLKitTokenizerPerformance
- (void)testTokenizerPerformance
{
NSString *path = [[NSBundle bundleForClass:self.class] resourcePath];
path = [path stringByAppendingPathComponent:@"Fixtures"];
path = [path stringByAppendingPathComponent:@"HTML Standard.html"];

NSString *string = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#import <XCTest/XCTest.h>
#import "HTMLDOM.h"
#import "HTMLKitTestUtil.h"

@interface HTMLKitNodeIteratorTests : XCTestCase

Expand Down Expand Up @@ -565,4 +566,30 @@ - (void)testRemoveReferenceNode_NodeAfterOldParentIsOutsideRoot_BeforeReference
XCTAssertEqual(iterator.pointerBeforeReferenceNode, NO);
}

#pragma mark - Bug Fixes

- (void)testBugFix_Issue_4
{
HTMLDocument *document = [HTMLDocument documentWithString:@"<ul><li>1<li>2"];

NSHashTable *nodeIterators = [HTMLKitTestUtil ivarForInstacne:document name:@"_nodeIterators"];
XCTAssertTrue([nodeIterators isKindOfClass:[NSHashTable class]]);

// document.body uses an iterator internally
HTMLElement *body = document.body;
XCTAssertNotNil(body);

// iterator should be deallocated and detached at this point
XCTAssertEqual(0, nodeIterators.count);

// iterator should be autoreleased, deallocated and detached after autoreleasepool
@autoreleasepool {
HTMLNodeIterator *iterator = [[HTMLNodeIterator alloc] initWithNode:body];
[iterator nextNode];
XCTAssertEqual(1, nodeIterators.count);
}

XCTAssertEqual(0, nodeIterators.count);
}

@end
File renamed without changes.
File renamed without changes.
20 changes: 20 additions & 0 deletions Tests/HTMLRangeTests.m → Tests/HTMLKitTests/HTMLRangeTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#import "HTMLDOM.h"
#import "HTMLNode+Private.h"
#import "HTMLRange+Private.h"
#import "HTMLKitTestUtil.h"

#define BodyOf(doc) doc.body.innerHTML
#define InnerHTML(str) [HTMLDocument documentWithString:str].body.innerHTML
Expand Down Expand Up @@ -2098,4 +2099,23 @@ - (void)testRangeStringifier
XCTAssertEqualObjects([range textContent], @"This is a textHelloWorldAnother text");
}

#pragma mark - Bug Fixes

- (void)testBugFix_Issue_5
{
HTMLDocument *document = [HTMLDocument documentWithString:@"<ul><li>1<li>2"];

NSHashTable *ranges = [HTMLKitTestUtil ivarForInstacne:document name:@"_ranges"];
XCTAssertTrue([ranges isKindOfClass:[NSHashTable class]]);

// range should be autoreleased, deallocated and detached after autoreleasepool
@autoreleasepool {
HTMLRange *range = [[HTMLRange alloc] initWithDowcument:document];
[range cloneContents];
XCTAssertEqual(1, ranges.count);
}

XCTAssertEqual(0, ranges.count);
}

@end
File renamed without changes.
File renamed without changes.

0 comments on commit b5470a6

Please sign in to comment.