How to use the inferno-compat.isValidElement 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 / lib / ReactFragment.js View on Github external
exports.create = function(obj) {
	var children = [];
	for (var key in obj) {
		if (obj.hasOwnProperty(key)) {
			var child = [].concat(obj[ key ]);
			for (var i = 0; i < child.length; i++) {
				var c = child[ i ];
				// if unkeyed, clone attrs and inject key
				if (inferno.isValidElement(c) && !(c.props && c.props.key)) {
					var a = {};
					if (c.props) for (var j in c.props) a[ j ] = c.props[ j ];
					a.key = key + '.' + i;
					c = inferno.createElement(c.type, a, c.children);
				}
				if (c != null) children.push(c);
			}
		}
	}
	return children;
};
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 = <span>{'child body text'}</span>;
      expect(isValidElement(child)).toBe(true);

      const element = <div>{child}</div>;
      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 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 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 = <span>first text</span>;
      expect(isValidElement(first_child)).toBe(true);

      const second_child = <span>second text</span>;
      expect(isValidElement(second_child)).toBe(true);

      const element = <div>{[first_child, second_child]}</div>;
      expect(isValidElement(element)).toBe(true);

      renderCompatTestElement(element);

      expect(container.innerHTML).toBe(innerHTML('<div><span>first text</span><span>second 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 = createElement('span', null, 'generated child body text');
        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__ / compat_children.spec.jsx View on Github external
it('Should render element with an iterable of one text string', function() {
        const iterable = arrayAsBasicIterator(['generated body text']);
        const element = createElement('div', null, iterable);
        expect(isValidElement(element)).toBe(true);

        renderCompatTestElement(element);

        expect(container.innerHTML).toBe(innerHTML('<div>generated body text</div>'));
      });
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 = <span>child body text</span>;
      expect(isValidElement(child)).toBe(true);

      const element = <div>{[child]}</div>;
      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 array of a string and a child element', function() {
      const second_child = <span>second text</span>;
      expect(isValidElement(second_child)).toBe(true);

      const element = <div>{['first text', second_child]}</div>;
      expect(isValidElement(element)).toBe(true);

      renderCompatTestElement(element);

      expect(container.innerHTML).toBe(innerHTML('<div>first text<span>second text</span></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>'));
    });