From 2602b6c9589df9445e8658a3049301d8b4bad48e Mon Sep 17 00:00:00 2001 From: Becky Siegel Date: Thu, 11 May 2017 11:20:12 -0700 Subject: [PATCH] Add root element definition Instead of appending/removing elements to document.body, add a global that defines what the root element is. This way, in apps that use elements with addional content outside, they will just need to set a root element. Change-Id: I0d01e4a6eea7d7d0af39989f1f831832506f1774 --- .../gr-tooltip-behavior.html | 2 ++ .../gr-tooltip-behavior.js | 2 +- .../elements/shared/gr-alert/gr-alert.html | 2 ++ .../app/elements/shared/gr-alert/gr-alert.js | 6 +++--- polygerrit-ui/app/scripts/rootElement.js | 20 +++++++++++++++++++ 5 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 polygerrit-ui/app/scripts/rootElement.js diff --git a/polygerrit-ui/app/behaviors/gr-tooltip-behavior/gr-tooltip-behavior.html b/polygerrit-ui/app/behaviors/gr-tooltip-behavior/gr-tooltip-behavior.html index 6b35328f8f..3e9e19e9c3 100644 --- a/polygerrit-ui/app/behaviors/gr-tooltip-behavior/gr-tooltip-behavior.html +++ b/polygerrit-ui/app/behaviors/gr-tooltip-behavior/gr-tooltip-behavior.html @@ -15,4 +15,6 @@ limitations under the License. --> + + diff --git a/polygerrit-ui/app/behaviors/gr-tooltip-behavior/gr-tooltip-behavior.js b/polygerrit-ui/app/behaviors/gr-tooltip-behavior/gr-tooltip-behavior.js index 8eb63a4b90..ad3f2c2372 100644 --- a/polygerrit-ui/app/behaviors/gr-tooltip-behavior/gr-tooltip-behavior.js +++ b/polygerrit-ui/app/behaviors/gr-tooltip-behavior/gr-tooltip-behavior.js @@ -75,7 +75,7 @@ // Set visibility to hidden before appending to the DOM so that // calculations can be made based on the element’s size. tooltip.style.visibility = 'hidden'; - Polymer.dom(document.body).appendChild(tooltip); + Gerrit.getRootElement().appendChild(tooltip); this._positionTooltip(tooltip); tooltip.style.visibility = null; diff --git a/polygerrit-ui/app/elements/shared/gr-alert/gr-alert.html b/polygerrit-ui/app/elements/shared/gr-alert/gr-alert.html index 10eadf9dc0..71cdec45d5 100644 --- a/polygerrit-ui/app/elements/shared/gr-alert/gr-alert.html +++ b/polygerrit-ui/app/elements/shared/gr-alert/gr-alert.html @@ -17,6 +17,8 @@ limitations under the License. + +