riot.render maximum call stack size exceeded when value=boolean #2038

Closed
willalbone opened this Issue Oct 24, 2016 · 3 comments

Projects

None yet

2 participants

@willalbone
  1. Describe your issue:
    Maximum call stack size is exceeded when calling riot.render where a DOM element has value attribute set to a boolean.
  2. Can you reproduce the issue?
    Save the files in this plunk locally and run node index.js
    http://plnkr.co/edit/N1W6lrEhETzviHbvmLho?p=preview
  3. On which browser/OS does the issue appear?
    Node 6.7.0
    MacOS 10.12
  4. Which version of Riot does it affect?
    Riot 2.6.4
  5. How would you tag this issue?
    • Question
    • Bug
    • Discussion
    • Feature request
    • Tip
    • Enhancement
    • Performance
@GianlucaGuarini GianlucaGuarini added the bug label Oct 24, 2016
@GianlucaGuarini
Member
GianlucaGuarini commented Oct 25, 2016 edited

I have tested the issue and it seems to work properly https://runkit.com/gianlucaguarini/580fa9f27432910013d48a3b. Are you sure you are using the latest riot release?

@GianlucaGuarini GianlucaGuarini added to verify and removed bug labels Oct 25, 2016
@willalbone

In your example setting this.value = true or false will cause it to fail, the call stack error only happens when setting an element value attribute to a boolean primitive.

RangeError: Maximum call stack size exceeded
    at String.toLowerCase (native)
    at Element.getAttribute (/Users/willalbone/dev/riot-render-sample/node_modules/simple-dom/dist/simple-dom.js:190:22)
    at Element.set (/Users/willalbone/dev/riot-render-sample/node_modules/riot/lib/server/sdom.js:39:14)
    at Element.set (/Users/willalbone/dev/riot-render-sample/node_modules/riot/lib/server/sdom.js:41:18)
    at Element.set (/Users/willalbone/dev/riot-render-sample/node_modules/riot/lib/server/sdom.js:41:18)
    at Element.set (/Users/willalbone/dev/riot-render-sample/node_modules/riot/lib/server/sdom.js:41:18)
    at Element.set (/Users/willalbone/dev/riot-render-sample/node_modules/riot/lib/server/sdom.js:41:18)
    at Element.set (/Users/willalbone/dev/riot-render-sample/node_modules/riot/lib/server/sdom.js:41:18)
    at Element.set (/Users/willalbone/dev/riot-render-sample/node_modules/riot/lib/server/sdom.js:41:18)
    at Element.set (/Users/willalbone/dev/riot-render-sample/node_modules/riot/lib/server/sdom.js:41:18)

See the sample repo https://github.com/willalbone/riot-render-sample

@GianlucaGuarini
Member

@willalbone ok thanks now I get it, I think the problem is that you can not set Boolean attributes for something that requires strings. This behavior is normalized in all browesers in runtime but we need to typecast these values in node. It should be really easy to fix it https://github.com/riot/riot/blob/8268ee60f1febdf09076a96ec257bbf59ba60c5a/lib/server/sdom.js#L40

In the meantime use this.myValue = 'true'

@GianlucaGuarini GianlucaGuarini added a commit that closed this issue Oct 31, 2016
@GianlucaGuarini GianlucaGuarini closes #2038 d7538d9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment