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.

Error : TypeError: Cannot read property 'isEmpty' of undefined

See original GitHub issue

I have a file containing a CSS portion that contains an error :

.k-carousel-slide img{min-width:0px;display:block;}}.container{width:1258px;margin:0 auto;}

You cann see the two } that crashes csso.

In this case, csso will completely fails even if it uses csstree (that is tolerant to this error).

Stack trace :

TypeError: Cannot read property 'isEmpty' of undefined
    at Object.cleanRuleset (csso/lib/clean/Rule.js:85:30)
    at Object.walk.leave (csso/lib/clean/index.js:16:37)
    at walkNode (csso/node_modules/css-tree/lib/walker/create.js:161:19)
    at List.each (csso/node_modules/css-tree/lib/utils/list.js:159:12)
    at Object.eval [as StyleSheet] (eval at createTypeIterator (csso/node_modules/css-tree/lib/walker/create.js:112:12), <anonymous>:5:15)
    at walkNode (csso/node_modules/css-tree/lib/walker/create.js:158:37)
    at walk (csso/node_modules/css-tree/lib/walker/create.js:214:9)
    at module.exports (csso/lib/clean/index.js:13:5)
    at compressChunk (csso/lib/compress.js:69:5)
    at compress (csso/lib/compress.js:154:9)

I think that the issue is related to the fact that the type Raw is not handled by csso.

Node that crashes csso :

{ type: 'Rule',
  loc: null,
  prelude: { type: 'Raw', loc: null, value: '}.container' },
  block:
   { type: 'Block',
     loc: null,
     children:
      { cursor: null,
        head:
         { prev: null,
           next:
            { prev: [Circular],
              next: null,
              data:
               { type: 'Declaration',
                 loc: null,
                 important: false,
                 property: 'margin',
                 value:
                  { type: 'Value',
                    loc: null,
                    children:
                     { cursor: null,
                       head:
                        { prev: null,
                          next:
                           { prev: [Circular],
                             next:
                              { prev: [Circular],
                                next: null,
                                data: { type: 'Identifier', loc: null, name: 'auto' } },
                             data: { type: 'WhiteSpace', loc: null, value: ' ' } },
                          data: { type: 'Number', loc: null, value: '0' } },
                       tail:
                        { prev:
                           { prev:
                              { prev: null,
                                next: [Circular],
                                data: { type: 'Number', loc: null, value: '0' } },
                             next: [Circular],
                             data: { type: 'WhiteSpace', loc: null, value: ' ' } },
                          next: null,
                          data: { type: 'Identifier', loc: null, name: 'auto' } } } } } },
           data:
            { type: 'Declaration',
              loc: null,
              important: false,
              property: 'width',
              value:
               { type: 'Value',
                 loc: null,
                 children:
                  { cursor: null,
                    head:
                     { prev: null,
                       next: null,
                       data: { type: 'Dimension', loc: null, value: '1258', unit: 'px' } },
                    tail:
                     { prev: null,
                       next: null,
                       data: { type: 'Dimension', loc: null, value: '1258', unit: 'px' } } } } } },
        tail:
         { prev:
            { prev: null,
              next: [Circular],
              data:
               { type: 'Declaration',
                 loc: null,
                 important: false,
                 property: 'width',
                 value:
                  { type: 'Value',
                    loc: null,
                    children:
                     { cursor: null,
                       head:
                        { prev: null,
                          next: null,
                          data: { type: 'Dimension', loc: null, value: '1258', unit: 'px' } },
                       tail:
                        { prev: null,
                          next: null,
                          data: { type: 'Dimension', loc: null, value: '1258', unit: 'px' } } } } } },
           next: null,
           data:
            { type: 'Declaration',
              loc: null,
              important: false,
              property: 'margin',
              value:
               { type: 'Value',
                 loc: null,
                 children:
                  { cursor: null,
                    head:
                     { prev: null,
                       next:
                        { prev: [Circular],
                          next:
                           { prev: [Circular],
                             next: null,
                             data: { type: 'Identifier', loc: null, name: 'auto' } },
                          data: { type: 'WhiteSpace', loc: null, value: ' ' } },
                       data: { type: 'Number', loc: null, value: '0' } },
                    tail:
                     { prev:
                        { prev:
                           { prev: null,
                             next: [Circular],
                             data: { type: 'Number', loc: null, value: '0' } },
                          next: [Circular],
                          data: { type: 'WhiteSpace', loc: null, value: ' ' } },
                       next: null,
                       data: { type: 'Identifier', loc: null, name: 'auto' } } } } } } } } }

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:14
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
lahmatiycommented, Oct 29, 2019

@abarre Fixed in 4.0.2. Notice that .container{ ... } block is removing since unpaired } breaks selector @horgh Your case is also fixed. Notice that both rules will be removed since selectors are invalid. @hansott CSSO is not crash in your case now. However, at-rule will be removed, because (min-width: 0 \0) is invalid. To fix that change it to (min-width: 0\0) (remove a whitespace before \0) – in this case hack will still work and at-rule will not be removed.

2reactions
RyanPWalkercommented, Jul 2, 2019

Any update on this? This is still a current bug.

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Cannot read property 'isEmpty' of undefined" error
API call is used for the initial data load. This issue occurs starting from the 2.8. 5 version of Flexmonster.
Read more >
Cannot read property 'isEmpty' of undefined when load multi ...
I following this example https://forge.autodesk.com/blog/aggregate-multi-models-sequence-forge-viewer for loading multi model into Forge Viewer ...
Read more >
TypeError: Cannot read property 'find' of Undefined in JS
The "Cannot read property 'find' of undefined" error occurs when the find() method is called on an undefined value. To solve the error,...
Read more >
[SOLVED] Cannot Read Property '0' of Undefined in JavaScript
The “cannot read property '0' of undefined” error occurs when you try to access the 0 index of an array-like variable, but the...
Read more >
How to Prevent the Error: Cannot Read Property '0' of Undefined
What is the Cannot Read Property '0' of Undefined Error ... undefined is a special value in JavaScript that is used to indicate...
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