nl_tokens: Switch the refinement applied over a facet / value
pl_tokens: function toggleHierarchicalFacetRefinement ( facet , value ) { if ( ! this . isHierarchicalFacet ( facet ) ) { throw new Error ( facet + ' is not defined in the hierarchicalFacets attribute of the helper configuration' ) ; } var separator = this . _getHierarchicalFacetSeparator ( this . getHierarchicalFacetByName ( facet ) ) ; var <mask> = { } ; var upOneOrMultipleLevel = this . hierarchicalFacetsRefinements [ facet ] !== undefined && this . hierarchicalFacetsRefinements [ facet ] . length > 0 && ( // remove current refinement: // refinement was 'beer > IPA', call is toggleRefine('beer > IPA'), refinement should be `beer` this . hierarchicalFacetsRefinements [ facet ] [ 0 ] === value || // remove a parent refinement of the current refinement: //  - refinement was 'beer > IPA > Flying dog' //  - call is toggleRefine('beer > IPA') //  - refinement should be `beer` this . hierarchicalFacetsRefinements [ facet ] [ 0 ] . indexOf ( value + separator ) === 0 ) ; if ( upOneOrMultipleLevel ) { if ( value . indexOf ( separator ) === - 1 ) { // go back to root level mod [ facet ] = [ ] ; } else { mod [ facet ] = [ value . slice ( 0 , value . lastIndexOf ( separator ) ) ] ; } } else { mod [ facet ] = [ value ] ; } return this . setQueryParameters ( { hierarchicalFacetsRefinements : defaults ( { } , mod , this . hierarchicalFacetsRefinements ) } ) ; }