Skip to content
This repository has been archived by the owner on Dec 3, 2020. It is now read-only.

Commit

Permalink
Rename hasDivWithPriceClass to hasPriceClass and udpate description.
Browse files Browse the repository at this point in the history
  • Loading branch information
biancadanforth committed Aug 3, 2018
1 parent a99d3ba commit 0a1b328
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/fathom_coefficients.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"hasDivWithPriceClass": 2
"hasPriceClass": 2
}
12 changes: 5 additions & 7 deletions src/fathom_extraction.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,14 @@
import {dom, out, rule, ruleset, score, type} from 'fathom-web';
import fathomCoeffs from 'commerce/fathom_coefficients.json';

const SCORE_THRESHOLD = fathomCoeffs.hasDivWithPriceClass;
const SCORE_THRESHOLD = fathomCoeffs.hasPriceClass;

/**
* Checks to see if an element is a <div> with a class of "price".
* Returns an integer corresponding to the coefficient to use for
* scoring an element with this rule.
* Scores fnodes with a "price" class
*/
function hasDivWithPriceClass(fnode) {
function hasPriceClass(fnode) {
if (fnode.element.classList.contains('price')) {
return fathomCoeffs.hasDivWithPriceClass;
return fathomCoeffs.hasPriceClass;
}
return 1;
}
Expand All @@ -35,7 +33,7 @@ const rules = ruleset(
rule(dom('div'), type('priceish')),

// check class names to see if they contain 'price'
rule(type('priceish'), score(hasDivWithPriceClass)),
rule(type('priceish'), score(hasPriceClass)),

// return price element with max score
rule(type('priceish').max(), out('product-price')),
Expand Down

0 comments on commit 0a1b328

Please sign in to comment.