Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CodeMirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Moritz Aurel Pascal Schubotz
CodeMirror
Commits
69669e4b
Commit
69669e4b
authored
8 years ago
by
John-David Dalton
Committed by
Marijn Haverbeke
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Avoid “Unspecified Error” in IE
when accessing `document.activeElement` from inside an iframe.
parent
6019b130
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/util/dom.js
+11
-9
11 additions, 9 deletions
src/util/dom.js
with
11 additions
and
9 deletions
src/util/dom.js
+
11
−
9
View file @
69669e4b
import
{
ie
,
ie_version
,
ios
}
from
"
./browser
"
import
{
ie
,
ios
}
from
"
./browser
"
export
function
classTest
(
cls
)
{
return
new
RegExp
(
"
(^|
\\
s)
"
+
cls
+
"
(?:$|
\\
s)
\\
s*
"
)
}
...
...
@@ -58,18 +58,20 @@ export function contains(parent, child) {
}
while
(
child
=
child
.
parentNode
)
}
export
let
activeElt
=
function
()
{
let
activeElement
=
document
.
activeElement
export
function
activeElt
()
{
// IE and Edge may throw an "Unspecified Error" when accessing document.activeElement.
// IE < 10 will throw when accessed while the page is loading or in an iframe.
// IE > 9 and Edge will throw when accessed in an iframe if document.body is unavailable.
let
activeElement
try
{
activeElement
=
document
.
activeElement
}
catch
(
e
)
{
activeElement
=
document
.
body
||
null
}
while
(
activeElement
&&
activeElement
.
root
&&
activeElement
.
root
.
activeElement
)
activeElement
=
activeElement
.
root
.
activeElement
return
activeElement
}
// Older versions of IE throws unspecified error when touching
// document.activeElement in some cases (during loading, in iframe)
if
(
ie
&&
ie_version
<
11
)
activeElt
=
function
()
{
try
{
return
document
.
activeElement
}
catch
(
e
)
{
return
document
.
body
}
}
export
function
addClass
(
node
,
cls
)
{
let
current
=
node
.
className
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment