Skip to content

Commit 34e80d8

Browse files
BatJannathanwoulfe
authored andcommitted
Use $document and don't try to add or remove if the element is not found
1 parent 506add2 commit 34e80d8

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
(function () {
22
"use strict";
33

4-
function focusLockService() {
5-
var elementToInert = document.querySelector('#mainwrapper');
4+
function focusLockService($document) {
5+
var elementToInert = $document[0].querySelector('#mainwrapper');
66

77
function addInertAttribute() {
8-
elementToInert.setAttribute('inert', true);
8+
if (elementToInert) {
9+
elementToInert.setAttribute('inert', true);
10+
}
911
}
1012

1113
function removeInertAttribute() {
12-
elementToInert.removeAttribute('inert');
14+
if (elementToInert) {
15+
elementToInert.removeAttribute('inert');
16+
}
1317
}
1418

1519
var service = {
@@ -20,7 +24,7 @@
2024
return service;
2125

2226
}
23-
27+
2428
angular.module("umbraco.services").factory("focusLockService", focusLockService);
2529

2630
})();

0 commit comments

Comments
 (0)