From f88e9107e1fa39d07636b07e2c581055306220f2 Mon Sep 17 00:00:00 2001 From: longsonr Date: Mon, 22 Jun 2020 18:46:35 +0000 Subject: [PATCH] Bug 1579186 - element.innerText should work with SVG text and foreignObject text r=dholbert Differential Revision: https://phabricator.services.mozilla.com/D80376 --- dom/base/nsRange.cpp | 8 +++++--- .../elements/the-innertext-idl-attribute/getter-tests.js | 4 ++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/dom/base/nsRange.cpp b/dom/base/nsRange.cpp index bd77f79ca3f0..6edbdc4b3bdd 100644 --- a/dom/base/nsRange.cpp +++ b/dom/base/nsRange.cpp @@ -3049,13 +3049,15 @@ struct InnerTextAccumulator { }; static bool IsVisibleAndNotInReplacedElement(nsIFrame* aFrame) { - if (!aFrame || !aFrame->StyleVisibility()->IsVisible()) { + if (!aFrame || !aFrame->StyleVisibility()->IsVisible() || + aFrame->HasAnyStateBits(NS_FRAME_IS_NONDISPLAY)) { return false; } for (nsIFrame* f = aFrame->GetParent(); f; f = f->GetParent()) { if (f->IsFrameOfType(nsIFrame::eReplaced) && - !f->GetContent()->IsHTMLElement(nsGkAtoms::button) && - !f->GetContent()->IsHTMLElement(nsGkAtoms::select)) { + !f->GetContent()->IsAnyOfHTMLElements(nsGkAtoms::button, + nsGkAtoms::select) && + !f->GetContent()->IsSVGElement()) { return false; } } diff --git a/testing/web-platform/tests/html/dom/elements/the-innertext-idl-attribute/getter-tests.js b/testing/web-platform/tests/html/dom/elements/the-innertext-idl-attribute/getter-tests.js index 34f3b0fa9c61..fd32e8d69a37 100644 --- a/testing/web-platform/tests/html/dom/elements/the-innertext-idl-attribute/getter-tests.js +++ b/testing/web-platform/tests/html/dom/elements/the-innertext-idl-attribute/getter-tests.js @@ -175,6 +175,10 @@ testText("abc", "", " contents ignored"); testText("
abc", "abc", "
contents ok for element not being rendered"); testText("abc", "", " alt text ignored"); testText("", "", " contents ignored"); +testText("
abc
", "abc", " text contents preserved"); +testText("
abc
", "", " text contents ignored"); +testText("
abc
", "", " non-rendered text ignored"); +testText("abc", "abc", " contents preserved"); /****