mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Merge pull request #2301 from teamcapybara/issue_2300
Fix getAttribute atom - issue #2300
This commit is contained in:
commit
8658b39d1c
4 changed files with 12 additions and 4 deletions
|
@ -1 +1 @@
|
|||
(function(){function u(e){var t=e.tagName.toUpperCase();if("OPTION"==t)return!0;if("INPUT"!=t)return!1;var r=e.type.toLowerCase();return"checkbox"==r||"radio"==r}function s(e){var t="selected",r=e.type&&e.type.toLowerCase();return"checkbox"!=r&&"radio"!=r||(t="checked"),!!e[t]}function c(e,t){var r=e.getAttributeNode(t);return r&&r.specified?r.value:null}var i=["allowfullscreen","allowpaymentrequest","allowusermedia","async","autofocus","autoplay","checked","compact","complete","controls","declare","default","defaultchecked","defaultselected","defer","disabled","ended","formnovalidate","hidden","indeterminate","iscontenteditable","ismap","itemscope","loop","multiple","muted","nohref","nomodule","noresize","noshade","novalidate","nowrap","open","paused","playsinline","pubdate","readonly","required","reversed","scoped","seamless","seeking","selected","truespeed","typemustmatch","willvalidate"],d={"class":"className",readonly:"readOnly"};return function f(e,t){var r=null,a=t.toLowerCase();if("style"==a)return(r=e.style)&&"string"!=typeof r&&(r=r.cssText),r;if(("selected"==a||"checked"==a)&&u(e))return s(e)?"true":null;if(tagName=e.tagName.toUpperCase(),"IMG"==tagName&&"src"==a||"A"==tagName&&"href"==a)return(r=c(e,a))&&(r=e[a]),r;if("spellcheck"==a){if(null===!(r=c(e,a))){if("false"==r.toLowerCase())return"false";if("true"==r.toLowerCase())return"true"}return e[a]+""}var l,n=d[t]||t;if(i.some(function(e){e==a}))return(r=!(null===(r=c(e,a)))||e[n])?"true":null;try{l=e[n]}catch(o){}return null!=(r=null==l||"object"==typeof l||"function"==typeof l?c(e,t):l)?r.toString():null}})()
|
||||
(function(){function u(e){var t=e.tagName.toUpperCase();if("OPTION"==t)return!0;if("INPUT"!=t)return!1;var r=e.type.toLowerCase();return"checkbox"==r||"radio"==r}function s(e){var t="selected",r=e.type&&e.type.toLowerCase();return"checkbox"!=r&&"radio"!=r||(t="checked"),!!e[t]}function c(e,t){var r=e.getAttributeNode(t);return r&&r.specified?r.value:null}var i=["allowfullscreen","allowpaymentrequest","allowusermedia","async","autofocus","autoplay","checked","compact","complete","controls","declare","default","defaultchecked","defaultselected","defer","disabled","ended","formnovalidate","hidden","indeterminate","iscontenteditable","ismap","itemscope","loop","multiple","muted","nohref","nomodule","noresize","noshade","novalidate","nowrap","open","paused","playsinline","pubdate","readonly","required","reversed","scoped","seamless","seeking","selected","truespeed","typemustmatch","willvalidate"],d={"class":"className",readonly:"readOnly"};return function f(e,t){var r=null,a=t.toLowerCase();if("style"==a)return(r=e.style)&&"string"!=typeof r&&(r=r.cssText),r;if(("selected"==a||"checked"==a)&&u(e))return s(e)?"true":null;if(tagName=e.tagName.toUpperCase(),"IMG"==tagName&&"src"==a||"A"==tagName&&"href"==a)return(r=c(e,a))&&(r=e[a]),r;if("spellcheck"==a){if(null!==(r=c(e,a))){if("false"==r.toLowerCase())return"false";if("true"==r.toLowerCase())return"true"}return e[a]+""}var l,n=d[t]||t;if(i.some(function(e){e==a}))return(r=!(null===(r=c(e,a)))||e[n])?"true":null;try{l=e[n]}catch(o){}return null!=(r=null==l||"object"==typeof l||"function"==typeof l?c(e,t):l)?r.toString():null}})()
|
|
@ -117,7 +117,7 @@
|
|||
|
||||
if ("spellcheck" == name) {
|
||||
value = getAttributeValue(element, name);
|
||||
if (!value === null) {
|
||||
if (!(value === null)) {
|
||||
if (value.toLowerCase() == "false") {
|
||||
return "false";
|
||||
} else if (value.toLowerCase() == "true") {
|
||||
|
|
|
@ -36,8 +36,8 @@
|
|||
</p>
|
||||
|
||||
<p>
|
||||
<input type="text" id="test_field" data-test-id="test_id" value="monkey"/>
|
||||
<input type="text" readonly="readonly" value="should not change" />
|
||||
<input type="text" id="test_field" spellcheck="TRUE" data-test-id="test_id" value="monkey"/>
|
||||
<input type="text" readonly="readonly" spellcheck="FALSE" value="should not change" />
|
||||
<textarea id="normal" data-other-test-id="test_id">
|
||||
banana</textarea>
|
||||
<textarea id="additional_newline">
|
||||
|
|
|
@ -27,6 +27,14 @@ RSpec.shared_examples 'Capybara::Node' do |session, _mode|
|
|||
end
|
||||
end
|
||||
|
||||
describe '#[]' do
|
||||
it 'should work for spellcheck' do
|
||||
session.visit('/with_html')
|
||||
expect(session.find('//input[@spellcheck="TRUE"]')[:spellcheck]).to eq('true')
|
||||
expect(session.find('//input[@spellcheck="FALSE"]')[:spellcheck]).to eq('false')
|
||||
end
|
||||
end
|
||||
|
||||
describe '#visible?' do
|
||||
let(:bridge) do
|
||||
session.driver.browser.send(:bridge)
|
||||
|
|
Loading…
Reference in a new issue