addons/firefox-addons/feed-preview

changeset 25:da483ce3832d

Fix selector for rel attributes

The rel attribute may contain a list of words to describe link relationships,
thus use the corect selector for that.
author Guido Berhoerster <guido+feed-preview@berhoerster.name>
date Fri Dec 28 12:27:16 2018 +0100 (17 months ago)
parents ff0393719d57
children f0c4a458869c
files content_scripts/feed-probe.js js/feed-parser.js
line diff
     1.1 --- a/content_scripts/feed-probe.js	Sun Dec 16 10:29:19 2018 +0100
     1.2 +++ b/content_scripts/feed-probe.js	Fri Dec 28 12:27:16 2018 +0100
     1.3 @@ -13,7 +13,7 @@
     1.4  function getFeeds() {
     1.5      let urlsFeeds = new Map();
     1.6      let elements = document.querySelectorAll(':-moz-any(link, a)[href]' +
     1.7 -            '[rel=alternate]:-moz-any([type="application/atom+xml"], ' +
     1.8 +            '[rel~=alternate]:-moz-any([type="application/atom+xml"], ' +
     1.9              '[type="application/rss+xml"])');
    1.10  
    1.11      for (let element of elements) {
     2.1 --- a/js/feed-parser.js	Sun Dec 16 10:29:19 2018 +0100
     2.2 +++ b/js/feed-parser.js	Fri Dec 28 12:27:16 2018 +0100
     2.3 @@ -341,7 +341,7 @@
     2.4          }
     2.5  
     2.6          let linkElement = feedQueryXPath(this.document, entryElement,
     2.7 -                './atom03:link[@href][@rel="alternate"]');
     2.8 +                './atom03:link[@href][@rel~="alternate"]');
     2.9          if (linkElement !== null) {
    2.10              link = parseURL(linkElement.getAttribute('href'), this.url);
    2.11          }
    2.12 @@ -515,7 +515,7 @@
    2.13          }
    2.14  
    2.15          let linkElement = feedQueryXPath(this.document, entryElement,
    2.16 -                './atom:link[@href][not(@rel) or @rel="alternate"]');
    2.17 +                './atom:link[@href][not(@rel) or @rel~="alternate"]');
    2.18          if (linkElement !== null) {
    2.19              link = parseURL(linkElement.getAttribute('href'), this.url);
    2.20          }
    2.21 @@ -540,7 +540,7 @@
    2.22          }
    2.23  
    2.24          for (let enclosureElement of feedQueryXPathAll(this.document,
    2.25 -                entryElement, './atom:link[@href][@rel="enclosure"]')) {
    2.26 +                entryElement, './atom:link[@href][@rel~="enclosure"]')) {
    2.27              try {
    2.28                  let entryFile = this.parseAtomEntryFile(enclosureElement);
    2.29                  files.push(entryFile);