Skip to content

Commit

Permalink
Clean up predicate finding
Browse files Browse the repository at this point in the history
  • Loading branch information
bergie committed Mar 8, 2011
1 parent c2ad804 commit 94c2b71
Showing 1 changed file with 18 additions and 31 deletions.
49 changes: 18 additions & 31 deletions vie.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,24 +181,17 @@
var entity;

if (typeof element === 'undefined') {
// We're working with the full document scope
element = jQuery(document);

// We're working with the full document scope, add the document itself as an entity
jQuery(VIE.RDFa.subjectSelector, element).andSelf().each(function() {
entity = VIE.RDFaEntities.getInstance(this);
if (entity) {
entities.push(entity);
}
});
} else {
jQuery(VIE.RDFa.subjectSelector, element).each(function() {
entity = VIE.RDFaEntities.getInstance(this);
if (entity) {
entities.push(entity);
}
});
}

jQuery(VIE.RDFa.subjectSelector, element).add(jQuery(element).filter(VIE.RDFa.subjectSelector)).each(function() {
entity = VIE.RDFaEntities.getInstance(this);
if (entity) {
entities.push(entity);
}
});

return entities;
}
},
Expand All @@ -209,6 +202,7 @@
Namespaces: {},

subjectSelector: '[about],[typeof],[src]',
predicateSelector: '[property],[rel]',

// Get a JSON-LD en
readEntity: function(element) {
Expand Down Expand Up @@ -256,24 +250,17 @@
var entity;

if (typeof element === 'undefined') {
// We're working with the full document scope
element = jQuery(document);

// We're working with the full document scope, add the document itself as an entity
jQuery(VIE.RDFa.subjectSelector, element).andSelf().each(function() {
entity = VIE.RDFa.readEntity(this);
if (entity) {
entities.push(entity);
}
});
} else {
jQuery(VIE.RDFa.subjectSelector, element).each(function() {
entity = VIE.RDFa.readEntity(this);
if (entity) {
entities.push(entity);
}
});
}

jQuery(VIE.RDFa.subjectSelector, element).add(jQuery(element).filter(VIE.RDFa.subjectSelector)).each(function() {
entity = VIE.RDFa.readEntity(this);
if (entity) {
entities.push(entity);
}
});

return entities;
},

Expand Down Expand Up @@ -394,7 +381,7 @@
},

findElementProperties: function(subject, element, allowPropertiesInProperties) {
return jQuery(element).find('[property],[rel]').add(jQuery(element).filter('[property],[rel]')).filter(function() {
return jQuery(element).find(VIE.RDFa.predicateSelector).add(jQuery(element).filter(VIE.RDFa.predicateSelector)).filter(function() {
if (VIE.RDFa.getSubject(this) !== subject) {
// The property is under another entity, skip
return false;
Expand Down

0 comments on commit 94c2b71

Please sign in to comment.