Skip to content

Commit

Permalink
use document documentElement
Browse files Browse the repository at this point in the history
  • Loading branch information
endiliey committed Dec 15, 2019
1 parent a100056 commit eb937aa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/docusaurus-theme-classic/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const path = require('path');
const storageKey = 'theme';
const noFlash = `(function() {
function setDataThemeAttribute(theme) {
document.querySelector('html').setAttribute('data-theme', theme);
document.documentElement.setAttribute('data-theme', theme);
}
function getPreferredTheme() {
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-theme-classic/src/theme/hooks/useTheme.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import * as React from 'react';
const useTheme = () => {
const [theme, setTheme] = React.useState(
typeof document !== 'undefined'
? document.querySelector('html').getAttribute('data-theme')
? document.documentElement.getAttribute('data-theme')
: '',
);

React.useEffect(() => {
document.querySelector('html').setAttribute('data-theme', theme);
document.documentElement.setAttribute('data-theme', theme);
}, [theme]);

React.useEffect(() => {
Expand Down

0 comments on commit eb937aa

Please sign in to comment.