Skip to content

Commit

Permalink
fix element always present assumptions
Browse files Browse the repository at this point in the history
  • Loading branch information
hazzuk committed Aug 23, 2024
1 parent 39a9f0b commit 236ca36
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion components/last-updated/last-updated.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
document.addEventListener("DOMContentLoaded", function () {
// Select the Ghost page meta element
const metaElement = document.querySelector('meta[property="article:modified_time"]');
// Select the components text element
// Try and select the components text element
const textElement = document.querySelector('.last-updated h4');
if (!textElement) {
return;
}

if (metaElement) {
// Get the pages last updated date
Expand Down
7 changes: 6 additions & 1 deletion components/obfuscated-email/obfuscated-email.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@
// you can obtain one at http://mozilla.org/MPL/2.0/.

document.addEventListener('DOMContentLoaded', function() {
// Select the components email link element
// Try and select the components email link element
const emailLinkElement = document.querySelector('.email-link');
if (!emailLinkElement) {
return;
}

// Create the email link from the data attributes
const user = emailLinkElement.getAttribute('data-user');
const domain = emailLinkElement.getAttribute('data-domain');
const email = user + '@' + domain;
Expand Down

0 comments on commit 236ca36

Please sign in to comment.