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.

babel#7.9.5 not working well with some self-closing tags

See original GitHub issue

Bug Report

Current Behavior Using babel with version 7.9.5, some self-closing tags like: <span><i class="fa fa-heart-o"/></span> do not get rendered well and then all the DOM will be broken. This behavior appears only with this version, with previous versions like 7.9.0 or above it works.

If you change the self-closing tag into a normal tag, the babel-preset-env work pretty well. <span><i class="fa fa-heart-o"></i></span>

Input Code

<div ng-if="ctrl.rooms && ctrl.rooms.length > 0" class="full-height dflex flex-direction-column">
            <div class="input-group col-lg-3 col-md-3 col-sm-5 col-xs-11 text-lg">
                <div class="input-group-addon" style="border:none; background-color:white; font-size: 18px;">
                    <span><i class="fa fa-heart-o"/></span>
                </div>
                <select class="form-control no-border-radius"
                        ng-options="item as item.label for item in ctrl.inChargeFilters track by item.id"
                        ng-model="ctrl.inChargeFilterSelected"
                        ng-change="ctrl.inChargeFilter()">
                </select>
            </div>
 ...

Expected behavior/code As shown in the screenshot, we have only a single heart icon, we see multiple heart icons rendered in the DOM with the version 7.9.5

Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)

  • Filename: webpack.config.js (babel snippet)
{
                    test: /.*(\/|\\)(?!app).*(\/|\\)(ctrls|dirs|module|svcs)(\/|\\).+\.js$/,
                    exclude: [/node_modules/],
                    use: [{
                        loader: 'babel-loader',
                        options: {
                            presets: ['@babel/preset-env']
                        }
                    }, {
                        loader: 'webpack-conditional-loader',
                    }]
                }
  • Filename: package.json (snippet)
"devDependencies": {
    "@babel/core": "^7.6.3",
    "@babel/preset-env": "^7.6.3",
    "babel-loader": "^8.0.6",
...

Environment


  • Babel version(s): v7.9.5
  • babel-preset-env version(s): v7.9.5
  • babel-loader version(s): v8.0.6
  • Node/npm version: Node 10.20.1 / npm 6.14.4
  • OS: Ubuntu 18.04
  • How you are using Babel: loader

Possible Solution To temporarily avoid this problem without rewriting the code, we suggest to downgrade babel-preset-env to 7.9.0

Additional context/Screenshots

Right render: Right DOM

Broken render: Broken DOM

Right DOM: Right DOM

Broken DOM: Broken DOM

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
uelercommented, Apr 22, 2020

We also have babel in our project and also suspected babel first for troubles with self closing tags.

However, in our case upgrading the dependency jquery to 3.5.0 (see their release notes) was responsible for messing up our whole AngularJS project. Back to 3.4.1 everything works fine again and self closing tags are fixed by jquery.

Maybe this is not directly related to this question, just in case someone has upgraded babel together with jquery.

2reactions
panthonycommented, Apr 16, 2020

Hello everyone 👋

I have the same issue as @AngeloAvv.

I have a dependency to spectrum which generate HTML with self-closing tags (see here using JavaScript.

Reverting back to a previous version of babel fixed the issue.

In my case I’m using babel through ember-cli-babel (https://github.com/babel/ember-cli-babel/releases/tag/v7.19.0).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problem while Testing ES6 Class with Jest - Stack Overflow
The error you are getting means that one of your presets isn't compatible with the babel version. Looking at your package.json you are...
Read more >
[Solved]-What does this code do?-babel.js - appsloveworld.com
Each function is expected to accept a single parameter. Its return value will be provided as an argument to the function standing to...
Read more >
Bug listing with status RESOLVED with resolution FIXED as at ...
... doesn't work properly" status:RESOLVED resolution:FIXED severity:normal ... Bug:761 - "Automatic bug reports on an ebuild failing" status:RESOLVED ...
Read more >
notices.txt - Thales Docs
... 7.8.3 : MIT License @babel/helper-function-name 7.9.5 : MIT License ... 7.12.13 : MIT License @babel/plugin-transform-react-jsx-self 7.9.0 : MIT License ...
Read more >
Keysight KCOS 9.17 Third Party & Open-Source License ...
@babel/helper-function-name 7.9.5 : MIT License. @babel/helper-get-function-arity ... @graphql-toolkit/graphql-tag-pluck 0.7.4 : MIT License.
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