Make Node#text work for svg elements
svg elements don't return to the non standard innerText attribute so fall back on the standard textContent when innerText is null. Fixes #437.
This commit is contained in:
parent
a70b7c4aa1
commit
2f3832fa15
|
@ -472,6 +472,26 @@ describe Capybara::Webkit::Driver do
|
|||
end
|
||||
end
|
||||
|
||||
context "svg app" do
|
||||
let(:driver) do
|
||||
driver_for_html(<<-HTML)
|
||||
<html>
|
||||
<body>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" height="100">
|
||||
<text x="10" y="25" fill="navy" font-size="15" id="navy_text">In the navy!</text>
|
||||
</svg>
|
||||
</body>
|
||||
</html>
|
||||
HTML
|
||||
end
|
||||
|
||||
before { visit("/") }
|
||||
|
||||
it "should handle text for svg elements" do
|
||||
driver.find("//*[@id='navy_text']").first.text.should == "In the navy!"
|
||||
end
|
||||
end
|
||||
|
||||
context "console messages app" do
|
||||
let(:driver) do
|
||||
driver_for_html(<<-HTML)
|
||||
|
|
|
@ -41,7 +41,7 @@ Capybara = {
|
|||
if (type == "textarea") {
|
||||
return node.innerHTML;
|
||||
} else {
|
||||
return node.innerText;
|
||||
return node.innerText || node.textContent;
|
||||
}
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in New Issue