import { ISelector } from 'svg-vdom' ; import { ISeletorPriority } from '../../typings/style' ; export const getSelectorPriority = ( seletors ) : ISeletorPriority => { const priority = { id : 0 , class : 0 , tag : 0 , } ; seletors . forEach ( seletor => { priority . id += seletor . id . length ; priority . class += seletor . class . length + seletor . pseudo . length + seletor . attr . length ; priority . tag += seletor . type ? 1 : 0 ; } ) ; return priority ; } ; export const overrideAble = ( priority1 , priority2 ) : boolean => { if ( priority1 . id !== priority2 . id ) { return priority1 . id > priority2 . id ; } else if ( priority1 . class !== priority2 . class ) { return priority1 . class > priority2 . class ; } else if ( priority1 . tag !== priority2 . tag ) { return priority1 . tag > priority2 . tag ; } return true ; } ;