diff --git a/src/Data.php b/src/Data.php index 72c6ab6..0557abf 100644 --- a/src/Data.php +++ b/src/Data.php @@ -188,8 +188,14 @@ private function extract_value_from_meta( array $attribute, ?int $post_id ) { */ private function extract_value_from_html( array $attribute, string $html, ?int $post_id = null ) { $value = null; + $html = trim( $html ); + + if ( empty( $html ) ) { + return null; + } + try { - $dom = new Document( trim( $html ) ); + $dom = new Document( $html ); $node = isset( $attribute['selector'] ) ? $dom->find( $attribute['selector'] ) : [ $dom->first( '*' ) ]; } catch ( InvalidSelectorException $e ) {