Skip to content

Wrong declaration of a block in the HTMLNodeFilterValue #22

@vladvlasov256

Description

@vladvlasov256

File HTMLNodeFilter.m:

@interface HTMLNodeFilterBlock ()
{
	BOOL (^ _block)(HTMLNode *);
}
@end

The _block must be an HTMLNodeFilterValue instead of BOOL. Possibly it was a typo.

This issue does nothing on simulators but it leads wrong behavior on devices.

Example:

HTMLDocument *document = [HTMLDocument documentWithString:@"<div id=\"id\"></div>"];
    
NSString *divId = @"id";
HTMLNodeFilterBlock *filter = [HTMLNodeFilterBlock filterWithBlock:^HTMLNodeFilterValue(HTMLNode * _Nonnull node) {
        HTMLElement *element = (HTMLElement *)node;
        return [element.elementId isEqualToString:divId] ? HTMLNodeFilterAccept : HTMLNodeFilterSkip;
}];
    
HTMLNodeIterator *iterator = [document nodeIteratorWithShowOptions:HTMLNodeFilterShowElement filter:filter];
    
HTMLElement *element = (HTMLElement*)iterator.nextObject;

On a simulator, the element is the div. But on a device, the element is the html.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions