How to use the inferno-compat.createElement function in inferno-compat

To help you get started, we’ve selected a few inferno-compat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github infernojs / inferno / packages / inferno-compat / __tests__ / svg.spec.jsx View on Github external
it('Should work with namespace svg attributes', () => {
    render(
      createElement('svg', null, [
        createElement('image', {
          xlinkHref: 'http://i.imgur.com/w7GCRPb.png'
        })
      ]),
      container
    );

    expect(container.firstChild.firstChild.tagName).toBe('image');
    expect(container.firstChild.firstChild.getAttribute('xlink:href')).toBe('http://i.imgur.com/w7GCRPb.png');
  });
});
github infernojs / inferno / packages / inferno-compat / __tests__ / compat_children.spec.jsx View on Github external
it('Should render element with an array of one child element', function() {
      const child = createElement('span', null, 'child body text');
      expect(isValidElement(child)).toBe(true);

      const element = createElement('div', null, [child]);
      expect(isValidElement(element)).toBe(true);

      renderCompatTestElement(element);

      expect(container.innerHTML).toBe(innerHTML('<div><span>child body text</span></div>'));
    });
github infernojs / inferno / packages / inferno-compat / __tests__ / compat_children.spec.jsx View on Github external
it('Should render element with an iterable of a child element and a string', function() {
        const child = <span>generated child body text</span>;
        expect(isValidElement(child)).toBe(true);

        const iterable = arrayAsBasicIterator([child, 'generated body text']);
        const element = createElement('div', null, iterable);
        expect(isValidElement(element)).toBe(true);

        renderCompatTestElement(element);

        expect(container.innerHTML).toBe(innerHTML('<div><span>generated child body text</span>generated body text</div>'));
      });
    }
github infernojs / inferno / packages / inferno-compat / __tests__ / svg.spec.jsx View on Github external
it('Should work with namespace svg attributes', () => {
    render(
      createElement('svg', null, [
        createElement('image', {
          xlinkHref: 'http://i.imgur.com/w7GCRPb.png'
        })
      ]),
      container
    );

    expect(container.firstChild.firstChild.tagName).toBe('image');
    expect(container.firstChild.firstChild.getAttribute('xlink:href')).toBe('http://i.imgur.com/w7GCRPb.png');
  });
});
github infernojs / inferno / packages / inferno-compat / __tests__ / ReactDOM.spec.jsx View on Github external
it('allows a DOM element to be used with a string', function() {
    var element = React.createElement('div', { className: 'foo' });
    var instance = renderIntoDocument(element);
    expect(ReactDOM.findDOMNode(instance).tagName).toBe('DIV');
  });
github infernojs / inferno / packages / inferno-compat / __tests__ / compat_children.spec.jsx View on Github external
it('Should render element with child element', function() {
      const child = createElement('span', null, 'child body text');
      expect(isValidElement(child)).toBe(true);

      const element = createElement('div', null, child);
      expect(isValidElement(element)).toBe(true);

      renderCompatTestElement(element);

      expect(container.innerHTML).toBe(innerHTML('<div><span>child body text</span></div>'));
    });
github infernojs / inferno / packages / inferno-compat / __tests__ / lifecycle.spec.jsx View on Github external
ref: el =&gt; {
                    console.log('2b' + (el ? el.id : null));
                  }
                },
                null
              )
            ]
          );
        }
      }

      render(createElement(Hello, { name: 'Inferno' }), container);

      console.log('UPDATE');

      render(createElement(Hello, { name: 'Better Lifecycle' }), container);

      console.log('REMOVAL');

      render(<div>, container);

      const array = consoleSpy.getCalls();
      expect(array.length).toEqual(42);

      /*
      React oder is:, Inferno will differenciate in string refs because they are handled same way as callback refs
      Will mount
      Will mount sub
      S2bS2b
      S1S1
      Didountsub
      4a4a</div>
github infernojs / inferno / packages / inferno-compat / __tests__ / compat_children.spec.jsx View on Github external
it('Should render element with an array of two child elements', function() {
      const first_child = createElement('span', null, 'first text');
      expect(isValidElement(first_child)).toBe(true);

      const second_child = createElement('span', null, 'second text');
      expect(isValidElement(second_child)).toBe(true);

      const element = createElement('div', null, [first_child, second_child]);
      expect(isValidElement(element)).toBe(true);

      renderCompatTestElement(element);

      expect(container.innerHTML).toBe(innerHTML('<div><span>first text</span><span>second text</span></div>'));
    });
github zanettin / inferno-apollo / src / graphql.tsx View on Github external
render() {
      const props = assign({}, this.props);
      props.client = this.client;
      if (operationOptions.withRef) props.ref = 'wrappedInstance';
      return createElement(WrappedComponent, props);
    }
  }
github zanettin / inferno-apollo / src / graphql.tsx View on Github external
render() {
        if (this.shouldSkip()) {
          return createElement(WrappedComponent, this.props);
        }

        const { shouldRerender, renderedElement, props } = this;
        this.shouldRerender = false;

        if (!shouldRerender && renderedElement && renderedElement.type === WrappedComponent) {
          return renderedElement;
        }

        const data = this.dataForChild();
        const clientProps = this.calculateResultProps(data);
        const mergedPropsAndData = assign({}, props, clientProps);

        if (operationOptions.withRef) mergedPropsAndData.ref = 'wrappedInstance';
        this.renderedElement = createElement(WrappedComponent, mergedPropsAndData);
        return this.renderedElement;