Refactor long if to function isSupportedElement.