#174 new


Reported by Thatcher | July 2nd, 2010 @ 07:30 AM

On Thu, Jul 1, 2010 at 9:58 PM, Dylan Just dylan.just@ephox.com wrote:

Hi John,

Sorry to trouble you, wonder if you could help.

I've found an issue in Envjs, but I'm unable to sign up to the Lighthouse issue tracking system - I get a server error.

The issue is when using jquery's .val() method on select tags, when using Envjs. The following code demonstrates it:

var x = $('<select><option value="value1">text1</option><option

value="value2" selected="selected">text2');


The first one prints "text2", the second prints "value2".

We've tracked it down to this section of jQuery's val method:

    if ( jQuery.nodeName( elem, "option" ) ) {
            return (elem.attributes.value || {}).specified ? elem.value

: elem.text;


For some reason, elem.attributes.value is not set by Envjs - it works fine in a browser. It only seems to affect option elements created like above. If I create the options using $("").attr("value", "myvalue"); it seems to be fine.

Would really appreciate if you could look into this, or pass off to someone else on the Envjs team to look at.

Many thanks,

Dylan Just Ephox

Comments and changes to this ticket

  • Gabriel Jürgens

    Gabriel Jürgens September 2nd, 2010 @ 04:56 AM

    • Assigned user set to “Thatcher”
    • Tag changed from jquery val to jquery val, htmloptionelement

    Hi! I think i'm having a problem related with this issue, but without using jQuery.

    Here is an example that throws a "Cannot find function add" error when running in Rhino:

    <option value="1">One</option>

    //JavaScript var oSelect = document.getElementById('oSelect');
    var oOption = document.createElement('OPTION');
    // Add the option to the collection first, then set properties oSelect.options.add(oOption);
    oOption.innerHTML = "Two";
    oOption.value = "2";

    I will try to make some more debugging and see if I can give you more info about this issue.

    Thanks for your great work, and sorry about my bad english!

  • Gabriel Jürgens

    Gabriel Jürgens September 2nd, 2010 @ 11:27 AM

    Sorry about my previous post!

    I'm a newie using lighthouse, and didn't saw the code snipplet, so here is again:

    <select id="oSelect">
    <script type="text/javascript">
    var oSelect = document.getElementById('oSelect');
    oSelect.options[0] = new Option("ONE",1);
    oSelect.options[1] = new Option("TWO",2);

    when I run this at Rhino using "env.rhino.js", I get this error:

    [  Envjs/1.6 (Rhino; U; Windows XP x86 5.1; en-US; rv:1.7.0.rc2) Resig/20070309 PilotFish/1.2.13  ]
    error loading script  [object HTMLScriptElement]   TypeError: Cannot read property "value" from undefined

    This example runs fine on Firefox, IE7, IE6, and Chrome, so I think it's an Envj issue.

    Sorry about my previous post!

  • Thatcher

    Thatcher September 22nd, 2010 @ 04:19 AM

    Thanks Gabriel,
    I'll integrate this into our unit tests and track down the issue. I expect
    it will be relatively easy to find given the good test case!

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

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

a javascript browser environment

People watching this ticket