`Maximum call stack size exceeded` error when nested tag attribute named `value` #1850

Closed
adrianblynch opened this Issue Jun 27, 2016 · 4 comments

Projects

None yet

3 participants

@adrianblynch

The issue

When rendering a parent tag, which includes a child tag with an attribute named value, a Maximum call stack size exceeded error is given.

To reproduce the issue

Base page:

const riot = require('riot')
const parentTag = require('./parent.tag')
const renderedParent = riot.render(parentTag)

Parent tag:

<parent>
    <p>Hello <child value={"World!"} /></p>
</parent>

Child tag:

<child>
    <span>{this.opts.value}</span>
</child>

Results in

/app/node_modules/riot/lib/server/sdom.js:40
    if (~['input', 'option', 'textarea'].indexOf(this.tagName.toLowerCase()))
                                         ^

RangeError: Maximum call stack size exceeded
    at Array.indexOf (native)
    at Element.Object.defineProperty.set (/app/node_modules/riot/lib/server/sdom.js:40:42)
    at Element.Object.defineProperty.set (/app/node_modules/riot/lib/server/sdom.js:43:18)
    at Element.Object.defineProperty.set (/app/node_modules/riot/lib/server/sdom.js:43:18)
    at Element.Object.defineProperty.set (/app/node_modules/riot/lib/server/sdom.js:43:18)
    at Element.Object.defineProperty.set (/app/node_modules/riot/lib/server/sdom.js:43:18)
    at Element.Object.defineProperty.set (/app/node_modules/riot/lib/server/sdom.js:43:18)
    at Element.Object.defineProperty.set (/app/node_modules/riot/lib/server/sdom.js:43:18)
    at Element.Object.defineProperty.set (/app/node_modules/riot/lib/server/sdom.js:43:18)
    at Element.Object.defineProperty.set (/app/node_modules/riot/lib/server/sdom.js:43:18)

Fix

Change value to something else, xxx:

<parent>
    <p>Hello <child xxx={"World!"} /></p>
</parent>
<child>
    <span>{this.opts.xxx}</span>
</child>

Environment

  • Node 6.2.1
  • Mac OS X 10.10.5
  • Riot 2.4.1

Possible tags

  • Bug
  • Discussion
  • Feature request
  • Tip
  • Enhancement
  • Performance
@cognitom
Member

I've confirmed this issue. It's ok on the browser, so it seems the issue only with simple-dom.

By the way, I think require('./child.tag') is also needed, too.

const riot = require('riot')
const parentTag = require('./parent.tag')
require('./child.tag')
const renderedParent = riot.render(parentTag)
@GianlucaGuarini
Member

This issue was already fixed d1f79f8

@cognitom
Member

Cool!

@GianlucaGuarini GianlucaGuarini referenced this issue Jun 29, 2016
Closed

infinite recursion in sdom.js #1856

1 of 7 tasks complete
@GianlucaGuarini
Member

fixed in riot@2.6.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment