Use a weak-memory NSHashTable for referencing iterators in HTML Document

This breaks the retain cycle between the document and the attached node
iterator.

Fixes #4
This commit is contained in:
iska
2017-02-22 23:54:55 +01:00
parent 9926179a62
commit 356709a096
4 changed files with 36 additions and 2 deletions
+2 -2
View File
@@ -20,8 +20,8 @@
@interface HTMLDocument ()
{
HTMLDocument *_inertTemplateDocument;
NSMutableArray *_nodeIterators;
NSMutableArray *_ranges;
NSHashTable *_nodeIterators;
}
@property (nonatomic, assign) HTMLDocumentReadyState readyState;
@end
@@ -41,8 +41,8 @@
self = [super initWithName:@"#document" type:HTMLNodeDocument];
if (self) {
_readyState = HTMLDocumentLoading;
_nodeIterators = [NSMutableArray new];
_ranges = [NSMutableArray new];
_nodeIterators = [[NSHashTable alloc] initWithOptions:NSHashTableWeakMemory capacity:10];
}
return self;
}