This project is archived and is in readonly mode.

#501 ✓invalid
Fábio M. Costa

Element constructor docs warning

Reported by Fábio M. Costa | November 28th, 2008 @ 04:50 PM | in 1.2.2

I usually use JSON objects like this:

{ key : 'value' }

instead of

{ 'key' : 'value' }

I had no problems until yesterday.

I tried to create a new Element like this:

var $newDiv = new Element('div',{
 class : 'test-class2',
 html : 'doesnt work at safari and ie6, maybe because class is a reserved word'

this doesnt work on safari and ie6, maybe because the 'class' word is a reserved one.

Both the examples bellow work ok:

var $otherNewDiv = new Element('div',{
 'class' : 'test-class2',
 'html' : 'works OK'

var $anotherNewDiv = new Element('div',{
 html : 'works OK'

You guys could just put a warning at the docs on the Element constructor. It could a comment after the 'class' key, something like:

'always use keys as strings'

Something like that... I've attached a html with the code so you guys can test.

Comments and changes to this ticket

  • Fábio M. Costa

    Fábio M. Costa November 28th, 2008 @ 04:51 PM

    • Title changed from “Element new documentation” to “Element constructor docs warning”
  • Tom Occhino

    Tom Occhino November 29th, 2008 @ 08:28 AM

    • Milestone changed from 2.0 to 1.2.2
    • State changed from “new” to “invalid”
    • Assigned user changed from “Jan Kassens” to “Tom Occhino”

    class is a reserved word in javascript and therefore may only be used as a key in an object literal in quotes. No documentation is needed since this is a JavaScript requirement, not a MooTools issue.

  • Fábio M. Costa

    Fábio M. Costa November 29th, 2008 @ 12:40 PM

    i was proposing a little warning for the mootools users, since the function works on some browsers.

  • Fábio M. Costa

    Fábio M. Costa November 29th, 2008 @ 12:48 PM

    And little warnings like this are good because some times you think that you are dealing with mootools problem when you are not, and then you get angry and bored with the framework. I thought it was a mootools issue at first, then i discovered it was this reserved key problem. And i'm not a javascript newbie.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

People watching this ticket