question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[QUESTION]: lazyload-wrapper class

See original GitHub issue

Hi @ameerthehacker, in the latest commit, you merged a pull request that added this span with the className lazyload-wrapper.

Is there a reason for this?

The previous behavior when the children was visible, was not to have any placeholder or wrapper around them.

Now because of this commit, it breaks my layout because of the extra span element with that class.

Is this the intended behavior?

Previous code:

return this.visible ? this.props.children : this.props.placeholder ? this.props.placeholder : _react2.default.createElement('div', { style: { height: this.props.height }, className: 'lazyload-placeholder' });

Now:

return _react2.default.createElement(
        'span',
        { className: 'lazyload-wrapper', ref: this.setRef },
        this.visible ? this.props.children : this.props.placeholder ? this.props.placeholder : _react2.default.createElement('div', {
          style: { height: this.props.height },
          className: 'lazyload-placeholder'
        })
      );

Please let me know, thanks!

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:6
  • Comments:33

github_iconTop GitHub Comments

11reactions
kbradleycommented, Jun 26, 2020

Could you consider also at least changing the tag from a span to a div?

Span tags are inline-level elements and should only contain “phrasing content”. If they are used to wrap block-level elements such as div tags then the HTML structure is invalid. In many usage cases users will end up wrapping block-level content which will result in an invalid HTML structure.

https://html.spec.whatwg.org/#the-span-element https://developer.mozilla.org/en-US/docs/Web/HTML/Element/span https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Content_categories#Phrasing_content

https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements “Content model Generally, inline elements may contain only data and other inline elements. You can’t put block elements inside inline elements.”

https://en.wikipedia.org/wiki/Span_and_div “For example, regardless of CSS, a span element may not contain block-level children”

5reactions
ameerthehackercommented, Jun 28, 2020

@simplecommerce @gilbarbara I have reverted back the old change as 2.6.9 and have released the breaking change as 3.0.0 to npm, @kbradley I have switched span tag with div. @Slapbox currently I’m not sure how to avoid the extra DOM node overhead but will keep thinking on it and meantime if you find any way to improve it feel free to raise a PR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Developers - [QUESTION]: lazyload-wrapper class - - Bountysource
Hi @ameerthehacker, in the latest commit, you merged a pull request that added this span with the className lazyload-wrapper . Is there a...
Read more >
How to lazy load a wrapper div containing a carousel with ...
I found a plugin called jquery-lazyloadanything but I can't figure out how to use it. http://jsfiddle.net/8bJUc/667/ <div class="lazy_wrap"> ...
Read more >
Using Lazy and abstract wrapper class to lazy-load complex ...
As a first step I will define base class for all lazy-loaded parameters. This class is wrapper around Lazy<T> and it also offers...
Read more >
Lazy Loading Design Pattern - GeeksforGeeks
Lazy loading is just a fancy name given to the process of initializing a class when it's actually needed. In simple words, Lazy...
Read more >
react-lazyload - npm
Installation · Now we have an extra div wrapping the lazy loaded component for the React ref to work · We can understand...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found