javascript - Casperjs visible() returns true while jquery is(':visible') returns false for the same selector -


casper.visible('#percent_med_pickup'); returns true, while following code same selector returns false:

casper.evaluate(function(){  return $('#percent_med_pickup').is(':visible'); }); 

aren't both same?

yes, different.

casperjs (source):

this.elementvisible = function elementvisible(elem) {     var style;     try {         style = window.getcomputedstyle(elem, null);     } catch (e) {         return false;     }     var hidden = style.visibility === 'hidden' || style.display === 'none';     if (hidden) {         return false;     }     if (style.display === "inline" || style.display === "inline-block") {         return true;     }     return elem.clientheight > 0 && elem.clientwidth > 0; }; 

jquery (source):

jquery.expr.filters.hidden = function( elem ) {     // support: opera <= 12.12     // opera reports offsetwidths , offsetheights less 0 on elements     return elem.offsetwidth <= 0 && elem.offsetheight <= 0; }; jquery.expr.filters.visible = function( elem ) {     return !jquery.expr.filters.hidden( elem ); }; 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -