Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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.
  • Loading branch information...
commit 2f3832fa153642a07649b6e449e3c2e70c6a5f9b 1 parent a70b7c4
@betelgeuse betelgeuse authored mhoran committed
Showing with 21 additions and 1 deletion.
  1. +20 −0 spec/driver_spec.rb
  2. +1 −1  src/capybara.js
View
20 spec/driver_spec.rb
@@ -472,6 +472,26 @@ def visit(url, driver=driver)
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)
View
2  src/capybara.js
@@ -41,7 +41,7 @@ Capybara = {
if (type == "textarea") {
return node.innerHTML;
} else {
- return node.innerText;
+ return node.innerText || node.textContent;
}
},
Please sign in to comment.
Something went wrong with that request. Please try again.