Add style.display check for inline-block when determining element visibility
When checking for visibility, style.display is checked to match “inline”. Added a check for “inline-block”.
Showing
2 changed files
with
21 additions
and
1 deletions
... | @@ -164,7 +164,7 @@ | ... | @@ -164,7 +164,7 @@ |
164 | if (hidden) { | 164 | if (hidden) { |
165 | return false; | 165 | return false; |
166 | } | 166 | } |
167 | if (style.display === "inline") { | 167 | if (style.display === "inline" || style.display === "inline-block") { |
168 | return true; | 168 | return true; |
169 | } | 169 | } |
170 | return elem.clientHeight > 0 && elem.clientWidth > 0; | 170 | return elem.clientHeight > 0 && elem.clientWidth > 0; | ... | ... |
... | @@ -201,3 +201,23 @@ casper.test.begin('ClientUtils.getElementsInfo() second element tests', 10, func | ... | @@ -201,3 +201,23 @@ casper.test.begin('ClientUtils.getElementsInfo() second element tests', 10, func |
201 | 'ClientUtils.getElementsInfo() retrieves second element whole tag contents'); | 201 | 'ClientUtils.getElementsInfo() retrieves second element whole tag contents'); |
202 | test.done(); | 202 | test.done(); |
203 | }); | 203 | }); |
204 | |||
205 | casper.test.begin('ClientUtils.getElementInfo() visibility tests', 4, function(test) { | ||
206 | casper.page.content = '<a href="plop" class="plip plup" style="display: inline"><i>paf</i></a>'; | ||
207 | var info = casper.getElementInfo('a.plip'); | ||
208 | test.assert(info.visible, 'ClientUtils.getElementInfo() retrieves element visibility with display inline'); | ||
209 | |||
210 | casper.page.content = '<a href="plop" class="plip plup" style="display: inline-block"><i>paf</i></a>'; | ||
211 | info = casper.getElementInfo('a.plip'); | ||
212 | test.assert(info.visible, 'ClientUtils.getElementInfo() retrieves element visibility with display inline-block'); | ||
213 | |||
214 | casper.page.content = '<a href="plop" class="plip plup" style="visibility: hidden"><i>paf</i></a>'; | ||
215 | info = casper.getElementInfo('a.plip'); | ||
216 | test.assertNot(info.visible, 'ClientUtils.getElementInfo() retrieves element visibility with visibility hidden'); | ||
217 | |||
218 | casper.page.content = '<a href="plop" class="plip plup" style="display: none"><i>paf</i></a>'; | ||
219 | info = casper.getElementInfo('a.plip'); | ||
220 | test.assertNot(info.visible, 'ClientUtils.getElementInfo() retrieves element visibility with display none'); | ||
221 | |||
222 | test.done(); | ||
223 | }); | ... | ... |
-
Please register or sign in to post a comment