Skip to content

Commit

Permalink
Fix: PR Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
sarvaje committed Mar 7, 2019
1 parent a7da3b2 commit 1158f2e
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions packages/hint/src/lib/utils/dom/get-element-by-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const getSrcsetUrls = (srcset: string): string[] => {
};

export default (dom: HTMLDocument, url: string): HTMLElement | null => {
// TODO: Cache dom.querySelectorAll?.
const elements = dom.querySelectorAll('[href],[src],[poster],[srcset]').filter((element: any) => {
const elementUrl = element.getAttribute('href') || element.getAttribute('src') || element.getAttribute('poster');
const elementUrls = [elementUrl, ...getSrcsetUrls(element.getAttribute('srcset'))];
Expand All @@ -33,6 +34,7 @@ export default (dom: HTMLDocument, url: string): HTMLElement | null => {
}

const absoluteUrls = elementUrls.map((relativeUrl) => {
// TODO: Cache the absolute URL, so we don't run new URL() for the same URL.
return new URL(relativeUrl, url).href;
});

Expand Down

0 comments on commit 1158f2e

Please sign in to comment.