Skip to content

Commit bf0d856

Browse files
committed
Merge branch 'release/2.1.4'
2 parents 8546168 + d29a70d commit bf0d856

File tree

8 files changed

+65
-9
lines changed

8 files changed

+65
-9
lines changed

.jazzy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module: HTMLKit
2-
module_version: 2.1.3
2+
module_version: 2.1.4
33
author: Iskandar Abudiab
44
author_url: https://twitter.com/iabudiab
55
github_url: https://github.com/iabudiab/HTMLKit

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Change Log
22

3+
## [2.1.4](https://github.com/iabudiab/HTMLKit/releases/tag/2.1.4)
4+
5+
Released on 2018.05.01
6+
7+
### Fixes
8+
9+
- `gt(n)`, `lt(n)` and `eq(n)` selectors would select wrong elements for the zero-index (issue #25)
10+
11+
312
## [2.1.3](https://github.com/iabudiab/HTMLKit/releases/tag/2.1.3)
413

514
Released on 2018.03.21

HTMLKit.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "HTMLKit"
3-
s.version = "2.1.3"
3+
s.version = "2.1.4"
44
s.summary = "HTMLKit, an Objective-C framework for your everyday HTML needs."
55
s.license = "MIT"
66
s.homepage = "https://github.com/iabudiab/HTMLKit"

HTMLKit.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111
62056C501E2AD9FB009A4EE0 /* HTMLNodeIterator+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 62056C4E1E2AD9FB009A4EE0 /* HTMLNodeIterator+Private.h */; settings = {ATTRIBUTES = (Private, ); }; };
1212
62056C511E2AD9FB009A4EE0 /* HTMLNodeIterator+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 62056C4E1E2AD9FB009A4EE0 /* HTMLNodeIterator+Private.h */; settings = {ATTRIBUTES = (Private, ); }; };
1313
62056C521E2AD9FB009A4EE0 /* HTMLNodeIterator+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 62056C4E1E2AD9FB009A4EE0 /* HTMLNodeIterator+Private.h */; settings = {ATTRIBUTES = (Private, ); }; };
14+
620AB7B12087F18D00AFCCC7 /* CSSStructuralPseudoSelectors.m in Sources */ = {isa = PBXBuildFile; fileRef = 620AB7B02087F18D00AFCCC7 /* CSSStructuralPseudoSelectors.m */; };
15+
620AB7B22087F18D00AFCCC7 /* CSSStructuralPseudoSelectors.m in Sources */ = {isa = PBXBuildFile; fileRef = 620AB7B02087F18D00AFCCC7 /* CSSStructuralPseudoSelectors.m */; };
16+
620AB7B32087F18D00AFCCC7 /* CSSStructuralPseudoSelectors.m in Sources */ = {isa = PBXBuildFile; fileRef = 620AB7B02087F18D00AFCCC7 /* CSSStructuralPseudoSelectors.m */; };
1417
62132E5A1C01F83200084175 /* CSSSelectorTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 62132E581C01F83200084175 /* CSSSelectorTest.m */; };
1518
62132E5D1C021FF200084175 /* css-tests in Resources */ = {isa = PBXBuildFile; fileRef = 62132E5B1C021FF200084175 /* css-tests */; };
1619
6216ACFD1C28DCC80074CAB4 /* CSSExtensionSelectorsParsingTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6216ACFC1C28DCC80074CAB4 /* CSSExtensionSelectorsParsingTests.m */; };
@@ -584,6 +587,7 @@
584587
/* Begin PBXFileReference section */
585588
62056C4E1E2AD9FB009A4EE0 /* HTMLNodeIterator+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "HTMLNodeIterator+Private.h"; path = "include/HTMLNodeIterator+Private.h"; sourceTree = "<group>"; };
586589
62079BE71AF56F1E00D3B402 /* CSSSelector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CSSSelector.h; path = include/CSSSelector.h; sourceTree = "<group>"; };
590+
620AB7B02087F18D00AFCCC7 /* CSSStructuralPseudoSelectors.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = CSSStructuralPseudoSelectors.m; path = HTMLKitTests/CSSStructuralPseudoSelectors.m; sourceTree = "<group>"; };
587591
620C87791BD44CBE00FB3EEE /* CSSCompoundSelector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CSSCompoundSelector.h; path = include/CSSCompoundSelector.h; sourceTree = "<group>"; };
588592
620C877A1BD44CBE00FB3EEE /* CSSCompoundSelector.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSSCompoundSelector.m; sourceTree = "<group>"; };
589593
620EE9471BC46F2A0028ED34 /* CSSPseudoClassSelector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CSSPseudoClassSelector.h; path = include/CSSPseudoClassSelector.h; sourceTree = "<group>"; };
@@ -1144,6 +1148,7 @@
11441148
624AB3191B050A4D00F3830D /* CSSAttributeSelectorTests.m */,
11451149
62F6586F1BD83C8E0045F137 /* CSSNThExpressionSelectorTests.m */,
11461150
621FBE5C1BDAD90200BC9555 /* CSSCombinatorSelectorTests.m */,
1151+
620AB7B02087F18D00AFCCC7 /* CSSStructuralPseudoSelectors.m */,
11471152
);
11481153
name = Selectors;
11491154
sourceTree = "<group>";
@@ -1750,6 +1755,7 @@
17501755
buildActionMask = 2147483647;
17511756
files = (
17521757
62EC0A851E158BD80007786B /* HTMLRangeTests.m in Sources */,
1758+
620AB7B12087F18D00AFCCC7 /* CSSStructuralPseudoSelectors.m in Sources */,
17531759
62E0BA971E25456700E4D193 /* HTMLCharacterDataTests.m in Sources */,
17541760
6216ACFD1C28DCC80074CAB4 /* CSSExtensionSelectorsParsingTests.m in Sources */,
17551761
62132E5A1C01F83200084175 /* CSSSelectorTest.m in Sources */,
@@ -1893,6 +1899,7 @@
18931899
buildActionMask = 2147483647;
18941900
files = (
18951901
62EC0A871E158BD80007786B /* HTMLRangeTests.m in Sources */,
1902+
620AB7B32087F18D00AFCCC7 /* CSSStructuralPseudoSelectors.m in Sources */,
18961903
62E0BA991E25456700E4D193 /* HTMLCharacterDataTests.m in Sources */,
18971904
62857D3B1D39A345008DC254 /* CSSSelectorTest.m in Sources */,
18981905
62857D421D39A345008DC254 /* CSSCombinatorSelectorTests.m in Sources */,
@@ -1981,6 +1988,7 @@
19811988
buildActionMask = 2147483647;
19821989
files = (
19831990
62EC0A861E158BD80007786B /* HTMLRangeTests.m in Sources */,
1991+
620AB7B22087F18D00AFCCC7 /* CSSStructuralPseudoSelectors.m in Sources */,
19841992
62E0BA981E25456700E4D193 /* HTMLCharacterDataTests.m in Sources */,
19851993
6216ACFE1C28DCC80074CAB4 /* CSSExtensionSelectorsParsingTests.m in Sources */,
19861994
62ECBFCA1C0B6E2E00AF847B /* HTML5LibTokenizerTest.m in Sources */,

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,8 @@ $ gem install cocoapods
7676
To add `HTMLKit` as a dependency into your project using CocoaPods just add the following in your `Podfile`:
7777

7878
```ruby
79-
use_frameworks!
80-
8179
target 'MyTarget' do
82-
pod 'HTMLKit', '~> 2.0'
80+
pod 'HTMLKit', '~> 2.1'
8381
end
8482
```
8583

Sources/CSSStructuralPseudoSelectors.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@
276276
return namedBlockSelector(name, ^BOOL(HTMLElement * _Nonnull element) {
277277
NSUInteger elementIndex = [element.parentElement indexOfChildNode:element];
278278

279-
if (index > 0) {
279+
if (index >= 0) {
280280
return elementIndex < index;
281281
} else {
282282
return elementIndex < element.parentElement.childNodesCount - index - 1;
@@ -290,7 +290,7 @@
290290
return namedBlockSelector(name, ^BOOL(HTMLElement * _Nonnull element) {
291291
NSUInteger elementIndex = [element.parentElement indexOfChildNode:element];
292292

293-
if (index > 0) {
293+
if (index >= 0) {
294294
return elementIndex > index;
295295
} else {
296296
return elementIndex > element.parentElement.childNodesCount - index - 1;
@@ -304,7 +304,7 @@
304304
return namedBlockSelector(name, ^BOOL(HTMLElement * _Nonnull element) {
305305
NSUInteger elementIndex = [element.parentElement indexOfChildNode:element];
306306

307-
if (index > 0) {
307+
if (index >= 0) {
308308
return elementIndex == index;
309309
} else {
310310
return elementIndex == element.parentElement.childNodesCount - index - 1;

Sources/HTMLKit-Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<key>CFBundlePackageType</key>
1818
<string>FMWK</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>2.1.3</string>
20+
<string>2.1.4</string>
2121
<key>CFBundleSignature</key>
2222
<string>????</string>
2323
<key>CFBundleVersion</key>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//
2+
// CSSStructuralPseudoSelectors.m
3+
// HTMLKit
4+
//
5+
// Created by Iska on 18.04.18.
6+
// Copyright © 2018 BrainCookie. All rights reserved.
7+
//
8+
9+
#import <XCTest/XCTest.h>
10+
#import "CSSSelectors.h"
11+
#import "HTMLParser.h"
12+
#import "HTMLDOM.h"
13+
14+
@interface CSSStructuralPseudoSelectors : XCTestCase
15+
16+
@end
17+
18+
@implementation CSSStructuralPseudoSelectors
19+
20+
#pragma mark - Bug Fixes
21+
22+
- (void)testBugFix_Issue_25
23+
{
24+
NSString *html = @"<table><tr><td>TD #0</td><td>TD #1</td><td>TD #2</td><td>TD #3</td></tr></table>";
25+
HTMLDocument *doc = [HTMLDocument documentWithString:html];
26+
NSArray<HTMLElement *> *elements = [doc querySelectorAll:@"td:gt(0)"];
27+
28+
XCTAssertEqual(elements.count, 3);
29+
XCTAssertEqualObjects(elements[0].textContent, @"TD #1");
30+
XCTAssertEqualObjects(elements[1].textContent, @"TD #2");
31+
XCTAssertEqualObjects(elements[2].textContent, @"TD #3");
32+
33+
elements = [doc querySelectorAll:@"td:lt(0)"];
34+
XCTAssertEqual(elements.count, 0);
35+
36+
elements = [doc querySelectorAll:@"td:eq(0)"];
37+
XCTAssertEqual(elements.count, 1);
38+
XCTAssertEqualObjects(elements[0].textContent, @"TD #0");
39+
}
40+
41+
@end

0 commit comments

Comments
 (0)