Skip to content

Commit c51b11e

Browse files
committed
Fixed issue paquettg#93
1 parent 4a267e3 commit c51b11e

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- Added new option `depthFirstSearch`.
1414
- Deprecated option `depthFirstSearch` and marked for removal in `3.0.0`.
1515
- Added multi class selections support.
16+
- Added case insensitive attribute matching
1617

1718
### Changed
1819
- Started using a changelog.

src/PHPHtmlParser/Dom/Tag.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ public function getAttributes()
283283
*/
284284
public function getAttribute(string $key)
285285
{
286+
$key = strtolower($key);
286287
if ( ! isset($this->attr[$key])) {
287288
return null;
288289
}

tests/DomTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,4 +452,24 @@ public function testFindDepthFirstSearch()
452452

453453
$this->assertEquals('<img src="http://example.com/first.jpg" />', (string)$images[0]);
454454
}
455+
456+
public function testCaseInSensitivity()
457+
{
458+
$str = "<FooBar Attribute='asdf'>blah</FooBar>";
459+
$dom = new Dom();
460+
$dom->loadStr($str);
461+
462+
$FooBar = $dom->find('FooBar');
463+
$this->assertEquals('asdf', $FooBar->attribute);
464+
}
465+
466+
public function testCaseSensitivity()
467+
{
468+
$str = "<FooBar Attribute='asdf'>blah</FooBar>";
469+
$dom = new Dom();
470+
$dom->loadStr($str);
471+
472+
$FooBar = $dom->find('FooBar');
473+
$this->assertEquals('asdf', $FooBar->Attribute);
474+
}
455475
}

0 commit comments

Comments
 (0)