diff options
author | Jyotsna Prakash <jyotsna.prakash@gmail.com> | 2017-06-21 20:34:21 -0700 |
---|---|---|
committer | Jyotsna Prakash <jyotsna.prakash@gmail.com> | 2017-06-22 10:04:06 -0700 |
commit | 433cd90bc305c74107c93fc04689239620ba22a8 (patch) | |
tree | f55768070c839b5ad8cc155055c9c0b788813cc7 /components/script/dom/globalscope.rs | |
parent | dfc44a0d35a1905247cddb926c99e87000b96b59 (diff) | |
download | servo-433cd90bc305c74107c93fc04689239620ba22a8.tar.gz servo-433cd90bc305c74107c93fc04689239620ba22a8.zip |
return Option from GlobalScope::current
handles the case where GlobalScope::current calls CurrentGlobalOrNull
and the result is null
Diffstat (limited to 'components/script/dom/globalscope.rs')
-rw-r--r-- | components/script/dom/globalscope.rs | 8 |
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)) + } } } |