GravityPDF / querypath

A fork of QueryPath: a PHP library for HTML(5)/XML querying (CSS 4 or XPath) and processing (like jQuery) with PHP8.3 support
Other
21 stars 2 forks source link

Reverse logic of html5() Method #43

Open jakejackson1 opened 1 year ago

jakejackson1 commented 1 year ago

Resolves issue where calling $qp('Content')->html5() would return an empty string, and calling $qp('Content')->html5('') would return Content. The correct logic, per ->html(), is to reverse how this method works.

Pull Request type

Please check the type of change your PR introduces:

What is the current behavior?

If you call html5() without a parameter it will return an empty string, instead of the currently loaded document.

What is the new behavior?

Calling html5() without a parameter will now correctly return the loaded document, and calling html5('markup') will correctly set the innerHTML of the currently selected Element.

Does this introduce a breaking change?

Technically, if users relied on the previous behavior this would be considered a breaking change. But the previous behavior is functionally incorrect. It should act just like ->html(), but using the HTML5() class.

Other information

TODO: Unit test

codecov[bot] commented 1 year ago

Codecov Report

Merging #43 (9b36844) into main (4280f56) will not change coverage. The diff coverage is 0.00%.

@@            Coverage Diff            @@
##               main      #43   +/-   ##
=========================================
  Coverage     88.40%   88.40%           
  Complexity     1349     1349           
=========================================
  Files            26       26           
  Lines          3088     3088           
=========================================
  Hits           2730     2730           
  Misses          358      358           
Impacted Files Coverage Δ
src/DOMQuery.php 82.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.