svg-namespace-matches.js 389 B

123456789101112131415161718
  1. import { closest } from '../core/utils';
  2. function svgNamespaceMatches(node, virtualNode) {
  3. try {
  4. const nodeName = virtualNode.props.nodeName;
  5. if (nodeName === 'svg') {
  6. return true;
  7. }
  8. // element is svg namespace if its parent is an svg element
  9. return !!closest(virtualNode, 'svg');
  10. } catch (e) {
  11. return false;
  12. }
  13. }
  14. export default svgNamespaceMatches;