Skip to content

Commit

Permalink
Use $document and don't try to add or remove if the element is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
BatJan authored and nathanwoulfe committed Sep 30, 2020
1 parent 506add2 commit 34e80d8
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
(function () {
"use strict";

function focusLockService() {
var elementToInert = document.querySelector('#mainwrapper');
function focusLockService($document) {
var elementToInert = $document[0].querySelector('#mainwrapper');

function addInertAttribute() {
elementToInert.setAttribute('inert', true);
if (elementToInert) {
elementToInert.setAttribute('inert', true);
}
}

function removeInertAttribute() {
elementToInert.removeAttribute('inert');
if (elementToInert) {
elementToInert.removeAttribute('inert');
}
}

var service = {
Expand All @@ -20,7 +24,7 @@
return service;

}

angular.module("umbraco.services").factory("focusLockService", focusLockService);

})();

0 comments on commit 34e80d8

Please sign in to comment.