Skip to content

Commit

Permalink
Merge branch '1.x' into targetselector-nullsafety
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/index.js
  • Loading branch information
ekremney committed Apr 18, 2024
2 parents e036f37 + 1e876f2 commit 845d3f7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# [1.15.0](https://github.com/adobe/helix-rum-enhancer/compare/v1.14.0...v1.15.0) (2024-04-18)


### Features

* add logic to capture target from wrapping anchor tag ([9f40d95](https://github.com/adobe/helix-rum-enhancer/commit/9f40d951021aa452b0cb8020c8ef1c2f5e68d069))

# [1.14.0](https://github.com/adobe/helix-rum-enhancer/compare/v1.13.2...v1.14.0) (2024-04-16)


Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adobe/helix-rum-enhancer",
"version": "1.14.0",
"version": "1.15.0",
"description": "Helix RUM Enhancer",
"main": "src/index.js",
"type": "module",
Expand Down
11 changes: 9 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,15 @@ new PerformanceObserver((list) => list

sampleRUM.targetselector = (element) => {
if (!element) return undefined;
let value = element.getAttribute('data-rum-target') || element.getAttribute('href') || element.currentSrc || element.getAttribute('src')
|| element.dataset.action || element.action;
const getTargetValue = (el) => el.getAttribute('data-rum-target') || el.getAttribute('href')
|| el.currentSrc || el.getAttribute('src')
|| el.dataset.action || el.action;

let value = getTargetValue(element);
if (!value && element.tagName !== 'A' && element.closest('a')) {
value = getTargetValue(element.closest('a'));
}

if (value && !value.startsWith('https://')) {
// resolve relative links
value = new URL(value, window.location).href;
Expand Down

0 comments on commit 845d3f7

Please sign in to comment.