ivopetkov / html5-dom-document-php

A better HTML5 parser for PHP.
MIT License
599 stars 40 forks source link

Feature attr class #17

Closed manychois closed 6 years ago

manychois commented 6 years ago

I found myself using this library a lot on class manipulation. It would be handy to have some jQuery-like methods hasClass(), addClass(), removeClass().

codecov-io commented 6 years ago

Codecov Report

Merging #17 into master will increase coverage by 0.41%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #17      +/-   ##
==========================================
+ Coverage   97.75%   98.16%   +0.41%     
==========================================
  Files           4        5       +1     
  Lines         623      709      +86     
==========================================
+ Hits          609      696      +87     
+ Misses         14       13       -1
Impacted Files Coverage Δ
src/HTML5DOMElement.php 98.78% <100%> (+1.34%) :arrow_up:
src/DOMTokenList.php 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 205dfa1...9375395. Read the comment docs.

manychois commented 6 years ago

Updated to increase unit test coverage.

ivopetkov commented 6 years ago

Thank you for the PR. What do you think about adding a classList attribute (like the one in https://developer.mozilla.org/en-US/docs/Web/API/Element/classList) instead of the methods?

manychois commented 6 years ago

That's even better idea, I can work on that. I'm more inclined to define a getter method classList() then using magic method __get(). What do you think?

ivopetkov commented 6 years ago

Wow. Great job. I think element.classList.add("anotherclass"); (instead of classList()) will be more familiar to the web developers and will better match the currently available innerHTML and outerHTML.