Skip to content

Incorrect results for some elements missing attributes #118

Closed
@aaronpk

Description

@aaronpk

There are a few cases where the parser is returning incorrect results because of the way it tests for the presence of attributes.

http://pin13.net/mf2/?id=20170524175046008

<article class="h-entry">
  <a class="u-url">link</a>
</article>

currently parses as

        {
            "type": [
                "h-entry"
            ],
            "properties": {
                "url": [
                    "http://example.com/"
                ],
                "name": [
                    "link"
                ]
            }
        }

The correct result should have the url property set to link.

This is caused by this incorrect conditional check: $u->getAttribute('href') !== null

The getAttribute method will never return null according to the PHP docs: http://php.net/manual/en/domelement.getattribute.php

The code should instead be testing for the presence of the attribute with hasAttribute

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions