Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'svgPath' of undefined #3794

Closed
palkerecsenyi opened this issue Apr 3, 2020 · 2 comments
Closed

Cannot read property 'svgPath' of undefined #3794

palkerecsenyi opened this issue Apr 3, 2020 · 2 comments
Assignees
Labels
issue: bug Describes why the code or behaviour is wrong

Comments

@palkerecsenyi
Copy link

palkerecsenyi commented Apr 3, 2020

Describe the bug

Recently, I upgraded my application to use NPM Blockly 3.20200123.0 instead of Blockly commit 3.20191014.4, and I started getting an issue whenever generating code with Blockly in headless mode (interestingly, this issue is completely non-existent when rendering in non-headless mode).

This issue is present only in 3.20200123.0 onwards; all other Blockly versions work fine.

Every time we tried to generate code, we got this error:

Uncaught TypeError: Cannot read property 'svgPath' of undefined
    at Blockly.FieldColour.doValueUpdate_ (field_colour.js:235)
    at Blockly.FieldColour.Blockly.Field.setValue (field.js:835)
    at Blockly.FieldColour.Blockly.Field.fromXml (field.js:392)
    at Object.Blockly.Xml.domToField_ (xml.js:798)
    at Object.Blockly.Xml.domToBlockHeadless_ (xml.js:691)
    at Object.Blockly.Xml.domToBlockHeadless_ (xml.js:705)
    at Object.Blockly.Xml.domToBlockHeadless_ (xml.js:729)
    at Object.Blockly.Xml.domToBlockHeadless_ (xml.js:729)
    at Object.Blockly.Xml.domToBlockHeadless_ (xml.js:729)
    at Object.Blockly.Xml.domToBlockHeadless_ (xml.js:729)

To Reproduce

This is the code we use to generate the code:

this.ffauWorkspace = new Blockly.Workspace();

// change the text to dom
const dom = Blockly.Xml.textToDom(xmlString);

// set the dom into the workspace
Blockly.Xml.domToWorkspace(dom, this.ffauWorkspace);

Our generators and block definitions can be found at https://github.com/codeddraig/ffau/tree/master/library/ffau.

The specific error shown above was experienced with the XML string found here: https://gist.github.com/palkerecsenyi/89ae1ae104ee005e2d5fde2d7104f2aa.

You can see the error in real life at https://codedragon.org/p/d7be8e0ec87a797e722cc71094407ba1 (headless mode). In non-headless mode, it works perfectly, as shown here: https://codedragon.org/editor/d7be8e0ec87a797e722cc71094407ba1.

Expected behavior

It should generate the following code string:

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>Coolest Button</title>
    <style>
      body{
      	padding-top: 20px;
      	padding-right: 20px;
      	padding-bottom: 20px;
      	padding-left: 20px;
      }
      .button{
      	background-color: #d55672;
      	padding-top: 20px;
      	padding-right: 20px;
      	padding-bottom: 20px;
      	padding-left: 20px;
      	border-radius: 5px;
      	border: 3px solid goldenrod;
      	color: white;
      		}
      .button:hover{
      	background-color: #e8a2b2;
      }
    </style>
  </head>
  <body>
    <p>  <a href="#" class="button">
        Hello
      </a>
    </p>
    <div style="padding-top: 30px;">
      <ul>
        <li>  <a href="http://bit.ly/cdr-button" target="_blank">
            Cool Buttons
          </a>
        </li>
        <li>  <a href="https://docs.google.com/presentation/d/1NL55snIpRMX4LwMe5M3QIJqDnM62Mx0TLE6XRrUgyjQ/edit?usp=sharing" target="_blank">
            More information
          </a>
        </li>
      </ul>
    </div>
  

</body></html>

Desktop (please complete the following information):

  • OS: macOS, Windows, Ubuntu 18.04
  • Browser: Chrome
  • Version: 80.0.3987.163

Thanks in advance for your help!

@palkerecsenyi palkerecsenyi added issue: triage Issues awaiting triage by a Blockly team member issue: bug Describes why the code or behaviour is wrong labels Apr 3, 2020
@samelhusseini samelhusseini self-assigned this Apr 3, 2020
@samelhusseini samelhusseini removed the issue: triage Issues awaiting triage by a Blockly team member label Apr 3, 2020
@palkerecsenyi
Copy link
Author

@samelhusseini this fixes it for me, it's working perfectly now. Thanks so much! I don't think I've ever seen a GitHub issue get resolved this fast.

@samelhusseini
Copy link
Contributor

Great, thanks for filing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
issue: bug Describes why the code or behaviour is wrong
Projects
None yet
Development

No branches or pull requests

2 participants