domql icon indicating copy to clipboard operation
domql copied to clipboard

Element not rendered (attached to document and ready to use) when `on.render` called

Open Nikaoto opened this issue 2 years ago • 0 comments

export const VirtuaList = {
  extend: Flex,
  props: {},
  intersectionObserver: {
    props: {
      height: 'D2',
      width: '100%',
      backgroundColor: 'darkGray',
    },
    on: {
      init: (el, props) => {
        setTimeout(() => {
          console.log(
            'Found element ',
            document.querySelector(`[key*=${el.key}]`)
          );
        }, 0);
      },
      render: (el, props) => {
        // This can't find the element
        console.log('render element', document.querySelector(`[key*=${el.key}]`))

        // But this can:
        setTimeout(() => {
          console.log(
            'render element ',
            document.querySelector(`[key*=${el.key}]`)
          );
        }, 0);
      },
    }
  },
  list: {},
};

In the first console.log, the element should be found, but it's not.

Nikaoto avatar Nov 14 '22 13:11 Nikaoto