Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

fix: Use head instead of body to detect edge pseudo var bug #4982

Merged
merged 3 commits into from
Aug 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/mdc-ripple/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ function detectEdgePseudoVarBug(windowObj: Window): boolean {
const document = windowObj.document;
const node = document.createElement('div');
node.className = 'mdc-ripple-surface--test-edge-var-bug';
document.body.appendChild(node);
// Append to head instead of body because this script might be invoked in the
// head, in which case the body doesn't exist yet. The probe works either way.
document.head.appendChild(node);
abhiomkar marked this conversation as resolved.
Show resolved Hide resolved

// The bug exists if ::before style ends up propagating to the parent element.
// Additionally, getComputedStyle returns null in iframes with display: "none" in Firefox,
Expand Down
3 changes: 3 additions & 0 deletions test/unit/mdc-ripple/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ export function createMockWindowForCssVariables() {
const getComputedStyle = td.func('window.getComputedStyle');
const remove = () => mockWindow.appendedNodes--;
const mockDoc = {
head: {
appendChild: () => mockWindow.appendedNodes++,
},
body: {
appendChild: () => mockWindow.appendedNodes++,
},
Expand Down