File tree Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Expand file tree Collapse file tree 2 files changed +17
-6
lines changed Original file line number Diff line number Diff line change 2121 // formatting props
2222 export let prefix = " " ;
2323 export let suffix = " " ;
24- export let formatter = (v ,i ) => v;
24+ export let formatter = (v ,i , p ) => v;
2525
2626 // stylistic props
2727 export let focus = undefined ;
210210 >
211211 {#if all === ' label' || first === ' label' }
212212 <span class =" pipVal" >
213- {#if prefix }<span class ="pipVal-prefix" >{prefix }</span >{/if }{formatter (fixFloat (min ),0 ,0 )}{#if suffix }<span class ="pipVal-suffix" >{suffix }</span >{/if }
213+ {#if prefix }<span class ="pipVal-prefix" >{prefix }</span >{/if }{@html formatter (fixFloat (min ),0 ,0 )}{#if suffix }<span class ="pipVal-suffix" >{suffix }</span >{/if }
214214 </span >
215215 {/if }
216216 </span >
229229 >
230230 {#if all === ' label' || rest === ' label' }
231231 <span class =" pipVal" >
232- {#if prefix }<span class ="pipVal-prefix" >{prefix }</span >{/if }{formatter (pipVal (i ),i ,percentOf (pipVal (i )))}{#if suffix }<span class ="pipVal-suffix" >{suffix }</span >{/if }
232+ {#if prefix }<span class ="pipVal-prefix" >{prefix }</span >{/if }{@html formatter (pipVal (i ),i ,percentOf (pipVal (i )))}{#if suffix }<span class ="pipVal-suffix" >{suffix }</span >{/if }
233233 </span >
234234 {/if }
235235 </span >
248248 >
249249 {#if all === ' label' || last === ' label' }
250250 <span class =" pipVal" >
251- {#if prefix }<span class ="pipVal-prefix" >{prefix }</span >{/if }{formatter (fixFloat (max ),pipCount ,100 )}{#if suffix }<span class ="pipVal-suffix" >{suffix }</span >{/if }
251+ {#if prefix }<span class ="pipVal-prefix" >{prefix }</span >{/if }{@html formatter (fixFloat (max ),pipCount ,100 )}{#if suffix }<span class ="pipVal-suffix" >{suffix }</span >{/if }
252252 </span >
253253 {/if }
254254 </span >
Original file line number Diff line number Diff line change 387387 }
388388 }
389389
390+ /**
391+ * helper to take a string of html and return only the text
392+ * @param {string} possibleHtml the string that may contain html
393+ * @return {string} the text from the input
394+ */
395+ function pureText (possibleHtml ) {
396+ const div = document .createElement (" div" );
397+ div .innerHTML = possibleHtml;
398+ return div .textContent || div .innerText || " " ;
399+ }
400+
390401 /**
391402 * when the user has unfocussed (blurred) from the
392403 * slider, deactivate all handles
832843 aria-valuemin ={range === true && index === 1 ? values [0 ] : min }
833844 aria-valuemax ={range === true && index === 0 ? values [1 ] : max }
834845 aria-valuenow ={value }
835- aria-valuetext =" {prefix }{handleFormatter (value ,index ,percentOf (value ))}{suffix }"
846+ aria-valuetext =" {prefix }{pureText ( handleFormatter (value ,index ,percentOf (value ) ))}{suffix }"
836847 aria-orientation ={vertical ? ' vertical' : ' horizontal' }
837848 aria-disabled ={disabled }
838849 {disabled }
841852 <span class =" rangeNub" />
842853 {#if float }
843854 <span class =" rangeFloat" >
844- {#if prefix }<span class ="rangeFloat-prefix" >{prefix }</span >{/if }{handleFormatter (value ,index ,percentOf (value ))}{#if suffix }<span class ="rangeFloat-suffix" >{suffix }</span >{/if }
855+ {#if prefix }<span class ="rangeFloat-prefix" >{prefix }</span >{/if }{@html handleFormatter (value ,index ,percentOf (value ))}{#if suffix }<span class ="rangeFloat-suffix" >{suffix }</span >{/if }
845856 </span >
846857 {/if }
847858 </span >
You can’t perform that action at this time.
0 commit comments