Skip to content

Conversation

@elexperimento
Copy link

@elexperimento elexperimento commented Oct 14, 2016

Dear team of querypath: Thanks for sharing your great work. The css function needed a correction, so that it had the expected behavior when applying the css function. I compared this behaviour with JQuery and fortunately JQuery DOES behave in the expected way, so querypath was the one behind. The error was as follows:
When making a css change, for example, if we wanted to change a color:
$qp($html, "p")->css("color", "blue");
the behaviour was unbelievable: all of the "p" tags ended up with the same styles! If, for example, one p tag had a style of "margin-bottom: 2px", then this rule would spread in ALL of the other "p" tags even though we originally wanted to change only the color (!!). This was due to the way in which the loop and the assignment of css style was done.

In this new version, now the assignment is as it should be, and as it works in JQuery: it ONLY CHANGES the specific attribute in the style of the css of each specific match element in the loop, without homogenizing the same style string for all of the matches.

If you disagree with approving the commit, do please think about it deeply, so you can see the improvement. The modifications to the original code are minimal.

I hope you apply this commit, specially for the future users of this great library.

Best regards from Colombia, South America.

David López
http://investigacionyprogramacion.com

Dear team of querypath: the css function needed a correction, so that it had the expected behavior when applying the css function. I compared this behaviour with JQuery and fortunately JQuery DOES behave in the expected matter, so querypath was the one behind. The error was as follows:
When making a css change, for example, we want to change a color:
 $qp($html, "p")->css("color", "blue");
but the behaviour was unbelievable: all of the "p" tags ended up with the same styles! If, for example, one <p> tag had a style of "margin-bottom: 2px", then this rule would spread in ALL of the other "<p>" tags even though we originally wanted to change only the color (!!). This was due to the way in which the loop and assignment of css style was assigned. 

Now the assignment is as it should be, and as it works in JQuery: ONLY CHANGE the specific attribute in the style of the css of each specific match element in the loop, without homogenizing the same style string for all of the matches.

Thanks, 

Best regards from Colombia, South America.

David López
http://investigacionyprogramacion.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant