Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
property is a white space separated list
Browse files Browse the repository at this point in the history
Property is a white space separated list of values and not a single value.
https://www.w3.org/TR/2008/REC-rdfa-syntax-20081014/#A-property

Check that matches have a content attribute.
  • Loading branch information
da2x committed Aug 27, 2018
1 parent f9ea116 commit 6a893a0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions addon/webextension/selector/documentMetadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
this.documentMetadata = (function() {

function findSiteName() {
let el = document.querySelector("meta[property='og:site_name']");
let el = document.querySelector("meta[property~='og:site_name'][content]");
if (el) {
return el.getAttribute("content");
}
// nytimes.com uses this property:
el = document.querySelector("meta[name='cre']");
el = document.querySelector("meta[name='cre'][content]");
if (el) {
return el.getAttribute("content");
}
Expand All @@ -29,7 +29,7 @@ this.documentMetadata = (function() {
profile:first_name profile:last_name profile:username profile:gender
`.split(/\s+/g);
for (const prop of openGraphProperties) {
let elems = document.querySelectorAll(`meta[property='og:${prop}']`);
let elems = document.querySelectorAll(`meta[property~='og:${prop}'][content]`);
if (forceSingle.includes(prop) && elems.length > 1) {
elems = [elems[0]];
}
Expand Down Expand Up @@ -63,7 +63,7 @@ this.documentMetadata = (function() {
player player:width player:height player:stream player:stream:content_type
`.split(/\s+/g);
for (const prop of properties) {
const elem = document.querySelector(`meta[name='twitter:${prop}']`);
const elem = document.querySelector(`meta[name='twitter:${prop}'][content]`);
if (elem) {
const value = elem.getAttribute("content");
if (value) {
Expand Down

0 comments on commit 6a893a0

Please sign in to comment.