aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/globalscope.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/globalscope.rs')
-rw-r--r--components/script/dom/globalscope.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs
index ce81958a2cb..3a47298c53b 100644
--- a/components/script/dom/globalscope.rs
+++ b/components/script/dom/globalscope.rs
@@ -543,12 +543,16 @@ impl GlobalScope {
///
/// ["current"]: https://html.spec.whatwg.org/multipage/#current
#[allow(unsafe_code)]
- pub fn current() -> Root<Self> {
+ pub fn current() -> Option<Root<Self>> {
unsafe {
let cx = Runtime::get();
assert!(!cx.is_null());
let global = CurrentGlobalOrNull(cx);
- global_scope_from_global(global)
+ if global.is_null() {
+ None
+ } else {
+ Some(global_scope_from_global(global))
+ }
}
}