Commit 2157726 1 parent 6d125ba commit 2157726 Copy full SHA for 2157726
File tree 2 files changed +15
-1
lines changed
2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -489,7 +489,11 @@ public function getElement()
489
489
*/
490
490
public function toElement ()
491
491
{
492
- return new Element ($ this ->getElement ());
492
+ if ($ this ->document ->documentElement === null ) {
493
+ throw new RuntimeException ('Cannot convert empty document to Element ' );
494
+ }
495
+
496
+ return new Element ($ this ->document ->documentElement );
493
497
}
494
498
495
499
/**
Original file line number Diff line number Diff line change @@ -477,6 +477,16 @@ public function testGetElement()
477
477
$ this ->assertInstanceOf ('DOMElement ' , $ document ->getElement ());
478
478
}
479
479
480
+ /**
481
+ * @expectedException RuntimeException
482
+ */
483
+ public function testEmptyDocumentToElement ()
484
+ {
485
+ $ document = new Document ();
486
+
487
+ $ document ->toElement ();
488
+ }
489
+
480
490
public function testToElement ()
481
491
{
482
492
$ html = $ this ->loadFixture ('posts.html ' );
You can’t perform that action at this time.
0 commit comments