Strange behavior querying HTML <select> tag

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Strange behavior querying HTML <select> tag

Manfred Kröhnert
Hi everyone,

I am experiencing a strange problem with latest HEAD revision (d8439ae4a).

Here is some test code which used to work before
SelectTest is a subclass of Widget.

SelectTest>>renderOn: html
  |select|
  select := html select with: [
    html option
      with: '--';
      value: 'abc'.
    html option
      with: '++';
      value: 'def'.
  ].
  select onChange: [:event |
    Transcript show: (select element); cr.
    Transcript show: (select element value); cr.
    Transcript show: (select element value value); cr.
  ].

Append this Widget to the body using

SelectTest new appendToJQuery: ('body' asJQuery)

The output is:

[object HTMLSelectElement]
[object HTMLSelectElement]
[object HTMLSelectElement]

However, at least the second line should produce a different output on
the Transcript.
Depending on the selected item it should either be 'abc' or 'def'.

If you do an inspect on (select element) there is definitely a 'value'
property with the correct value.
But inspecting (select element value) leads to the same inspector and
not to the value object.

Any ideas?

Best,
Manfred
Reply | Threaded
Open this post in threaded view
|

Re: Strange behavior querying HTML <select> tag

Nicolas Petton
Hi!

What if you inspect "select element" on change event?

Nico


2012/11/1 Manfred Kröhnert <[hidden email]>
Hi everyone,

I am experiencing a strange problem with latest HEAD revision (d8439ae4a).

Here is some test code which used to work before
SelectTest is a subclass of Widget.

SelectTest>>renderOn: html
  |select|
  select := html select with: [
    html option
      with: '--';
      value: 'abc'.
    html option
      with: '++';
      value: 'def'.
  ].
  select onChange: [:event |
    Transcript show: (select element); cr.
    Transcript show: (select element value); cr.
    Transcript show: (select element value value); cr.
  ].

Append this Widget to the body using

SelectTest new appendToJQuery: ('body' asJQuery)

The output is:

[object HTMLSelectElement]
[object HTMLSelectElement]
[object HTMLSelectElement]

However, at least the second line should produce a different output on
the Transcript.
Depending on the selected item it should either be 'abc' or 'def'.

If you do an inspect on (select element) there is definitely a 'value'
property with the correct value.
But inspecting (select element value) leads to the same inspector and
not to the value object.

Any ideas?

Best,
Manfred

Reply | Threaded
Open this post in threaded view
|

Re: Strange behavior querying HTML <select> tag

Manfred Kröhnert
Hi Nico,

On Fri, Nov 2, 2012 at 1:02 PM, nicolas petton <[hidden email]> wrote:
Hi!

What if you inspect "select element" on change event?

Nico


Yes, that is what I already did.
I put the following two lines inside of the on change event handling block:

    (select element) inspect.
    (select element value) inspect.

Both of them open the same inspector entitled "[object HTMLSelectElement]" and each showing the correct value for the "value" property.
Doing a "self value inspect" in the inspectors source area also opens the same inspector again and does not show a value "object".

Manfred

 
2012/11/1 Manfred Kröhnert <[hidden email]>
Hi everyone,

I am experiencing a strange problem with latest HEAD revision (d8439ae4a).

Here is some test code which used to work before
SelectTest is a subclass of Widget.

SelectTest>>renderOn: html
  |select|
  select := html select with: [
    html option
      with: '--';
      value: 'abc'.
    html option
      with: '++';
      value: 'def'.
  ].
  select onChange: [:event |
    Transcript show: (select element); cr.
    Transcript show: (select element value); cr.
    Transcript show: (select element value value); cr.
  ].

Append this Widget to the body using

SelectTest new appendToJQuery: ('body' asJQuery)

The output is:

[object HTMLSelectElement]
[object HTMLSelectElement]
[object HTMLSelectElement]

However, at least the second line should produce a different output on
the Transcript.
Depending on the selected item it should either be 'abc' or 'def'.

If you do an inspect on (select element) there is definitely a 'value'
property with the correct value.
But inspecting (select element value) leads to the same inspector and
not to the value object.

Any ideas?

Best,
Manfred

Reply | Threaded
Open this post in threaded view
|

Re: Strange behavior querying HTML <select> tag

vpena
Hi,

I think I have the same error. If I do:

(<document.getElementById('textToView').value>) -> 'text'

(document getElementById: 'textToView') value -> [object HTMLTextAreaElement]

Cheers,
Vanessa.


On 11/02/2012 05:13 PM, Manfred Kröhnert [via Smalltalk] wrote:
Hi Nico,

On Fri, Nov 2, 2012 at 1:02 PM, nicolas petton <[hidden email]> wrote:
Hi!

What if you inspect "select element" on change event?

Nico


Yes, that is what I already did.
I put the following two lines inside of the on change event handling block:

    (select element) inspect.
    (select element value) inspect.

Both of them open the same inspector entitled "[object HTMLSelectElement]" and each showing the correct value for the "value" property.
Doing a "self value inspect" in the inspectors source area also opens the same inspector again and does not show a value "object".

Manfred

 
2012/11/1 Manfred Kröhnert <[hidden email]>
Hi everyone,

I am experiencing a strange problem with latest HEAD revision (d8439ae4a).

Here is some test code which used to work before
SelectTest is a subclass of Widget.

SelectTest>>renderOn: html
  |select|
  select := html select with: [
    html option
      with: '--';
      value: 'abc'.
    html option
      with: '++';
      value: 'def'.
  ].
  select onChange: [:event |
    Transcript show: (select element); cr.
    Transcript show: (select element value); cr.
    Transcript show: (select element value value); cr.
  ].

Append this Widget to the body using

SelectTest new appendToJQuery: ('body' asJQuery)

The output is:

[object HTMLSelectElement]
[object HTMLSelectElement]
[object HTMLSelectElement]

However, at least the second line should produce a different output on
the Transcript.
Depending on the selected item it should either be 'abc' or 'def'.

If you do an inspect on (select element) there is definitely a 'value'
property with the correct value.
But inspecting (select element value) leads to the same inspector and
not to the value object.

Any ideas?

Best,
Manfred




If you reply to this email, your message will be added to the discussion below:
http://forum.world.st/Strange-behavior-querying-HTML-select-tag-tp4653501p4653810.html
To start a new topic under Amber Smalltalk, email [hidden email]
To unsubscribe from Amber Smalltalk, click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: Strange behavior querying HTML <select> tag

Manfred Kröhnert
In reply to this post by Manfred Kröhnert
Hi,

I think I might have found what lead to the following error:

On Thu, Nov 1, 2012 at 4:12 PM, Manfred Kröhnert <[hidden email]> wrote:
Hi everyone,

I am experiencing a strange problem with latest HEAD revision (d8439ae4a).

Here is some test code which used to work before
SelectTest is a subclass of Widget.

SelectTest>>renderOn: html
  |select|
  select := html select with: [
    html option
      with: '--';
      value: 'abc'.
    html option
      with: '++';
      value: 'def'.
  ].
  select onChange: [:event |
    Transcript show: (select element); cr.
    Transcript show: (select element value); cr.
    Transcript show: (select element value value); cr.
  ].

Append this Widget to the body using

SelectTest new appendToJQuery: ('body' asJQuery)

The output is:

[object HTMLSelectElement]
[object HTMLSelectElement]
[object HTMLSelectElement]

However, at least the second line should produce a different output on
the Transcript.
Depending on the selected item it should either be 'abc' or 'def'.

If you do an inspect on (select element) there is definitely a 'value'
property with the correct value.
But inspecting (select element value) leads to the same inspector and
not to the value object.

Any ideas?

Best,
Manfred

Commit 85133ae99027d728a616f50f7cbcc88ba45c98d5 introduced the method Object>>value which returns 'self'.
Since (select element) is of type Object the statement (select element value) will always return 'self'.
This leads to the multiple output of [object HTMLSelectElement] since each >>value message now answers self.

The inspector on the other hand does not use the >>value message to print the contents of the object and hence it displays the correct string when selecting 'value'.

Now the question is how to deal with this problem since most HTML seem to have a member named 'value' and accessing it does not conform to the rules on how to access object properties of non-Smalltalk objects.

Best,
Manfred

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Strange behavior querying HTML <select> tag

Herby Vojčík


Manfred Kröhnert wrote:

> Hi,
>
> I think I might have found what lead to the following error:
>
> On Thu, Nov 1, 2012 at 4:12 PM, Manfred Kröhnert
> <[hidden email] <mailto:[hidden email]>> wrote:
>
>     Hi everyone,
>
>     I am experiencing a strange problem with latest HEAD revision
>     (d8439ae4a).
>
>     Here is some test code which used to work before
>     SelectTest is a subclass of Widget.
>
>     SelectTest>>renderOn: html
>        |select|
>        select := html select with: [
>          html option
>            with: '--';
>            value: 'abc'.
>          html option
>            with: '++';
>            value: 'def'.
>        ].
>        select onChange: [:event |
>          Transcript show: (select element); cr.
>          Transcript show: (select element value); cr.
>          Transcript show: (select element value value); cr.
>        ].
>
>     Append this Widget to the body using
>
>     SelectTest new appendToJQuery: ('body' asJQuery)
>
>     The output is:
>
>     [object HTMLSelectElement]
>     [object HTMLSelectElement]
>     [object HTMLSelectElement]
>
>     However, at least the second line should produce a different output on
>     the Transcript.
>     Depending on the selected item it should either be 'abc' or 'def'.
>
>     If you do an inspect on (select element) there is definitely a 'value'
>     property with the correct value.
>     But inspecting (select element value) leads to the same inspector and
>     not to the value object.
>
>     Any ideas?
>
>     Best,
>     Manfred
>
>
> Commit 85133ae99027d728a616f50f7cbcc88ba45c98d5 introduced the method
> Object>>value which returns 'self'.
> Since (select element) is of type Object the statement (select element
> value) will always return 'self'.
> This leads to the multiple output of [object HTMLSelectElement] since
> each >>value message now answers self.
>
> The inspector on the other hand does not use the >>value message to
> print the contents of the object and hence it displays the correct
> string when selecting 'value'.
>
> Now the question is how to deal with this problem since most HTML seem
> to have a member named 'value' and accessing it does not conform to the
> rules on how to access object properties of non-Smalltalk objects.

Either
  1. learn to use attr: 'value', at: 'value', basicAt: 'value' etc. or
  2. rewrite JSObjectProxy's value to try JS .value first

> Best,
> Manfred

Herby

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: Strange behavior querying HTML <select> tag

Nicolas Petton

It can be quite inconvenient. That's the problem of using a
semi-transparent proxy. OTOH, it is consistent with Smalltalk.

Maybe JSObjectProxy >> value could handle this? Do you think it may be
worth it?

Nico


Herby Vojčík <[hidden email]> writes:

> Manfred Kröhnert wrote:
>> Hi,
>>
>> I think I might have found what lead to the following error:
>>
>> On Thu, Nov 1, 2012 at 4:12 PM, Manfred Kröhnert
>> <[hidden email] <mailto:[hidden email]>> wrote:
>>
>>     Hi everyone,
>>
>>     I am experiencing a strange problem with latest HEAD revision
>>     (d8439ae4a).
>>
>>     Here is some test code which used to work before
>>     SelectTest is a subclass of Widget.
>>
>>     SelectTest>>renderOn: html
>>        |select|
>>        select := html select with: [
>>          html option
>>            with: '--';
>>            value: 'abc'.
>>          html option
>>            with: '++';
>>            value: 'def'.
>>        ].
>>        select onChange: [:event |
>>          Transcript show: (select element); cr.
>>          Transcript show: (select element value); cr.
>>          Transcript show: (select element value value); cr.
>>        ].
>>
>>     Append this Widget to the body using
>>
>>     SelectTest new appendToJQuery: ('body' asJQuery)
>>
>>     The output is:
>>
>>     [object HTMLSelectElement]
>>     [object HTMLSelectElement]
>>     [object HTMLSelectElement]
>>
>>     However, at least the second line should produce a different output on
>>     the Transcript.
>>     Depending on the selected item it should either be 'abc' or 'def'.
>>
>>     If you do an inspect on (select element) there is definitely a 'value'
>>     property with the correct value.
>>     But inspecting (select element value) leads to the same inspector and
>>     not to the value object.
>>
>>     Any ideas?
>>
>>     Best,
>>     Manfred
>>
>>
>> Commit 85133ae99027d728a616f50f7cbcc88ba45c98d5 introduced the method
>> Object>>value which returns 'self'.
>> Since (select element) is of type Object the statement (select element
>> value) will always return 'self'.
>> This leads to the multiple output of [object HTMLSelectElement] since
>> each >>value message now answers self.
>>
>> The inspector on the other hand does not use the >>value message to
>> print the contents of the object and hence it displays the correct
>> string when selecting 'value'.
>>
>> Now the question is how to deal with this problem since most HTML seem
>> to have a member named 'value' and accessing it does not conform to the
>> rules on how to access object properties of non-Smalltalk objects.
>
> Either
>   1. learn to use attr: 'value', at: 'value', basicAt: 'value' etc. or
>   2. rewrite JSObjectProxy's value to try JS .value first
>
>> Best,
>> Manfred
>
> Herby
>
> --
> You received this message because you are subscribed to the Google Groups "amber-lang" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
Nicolas Petton
http://nicolas-petton.fr

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: Strange behavior querying HTML <select> tag

Manfred Kröhnert

Hi,

I can make a pull request to add a >>value method to JSObjectProxy which its able to handle this case.

The question is if this is a wanted addition and if make the same changes if other cases like this one appear.
Or, if we tell people accessing JS objecs through a proxy to always use >>at:.

Best,
Manfred

Am 20.02.2013 16:11 schrieb "Nicolas Petton" <[hidden email]>:

It can be quite inconvenient. That's the problem of using a
semi-transparent proxy. OTOH, it is consistent with Smalltalk.

Maybe JSObjectProxy >> value could handle this? Do you think it may be
worth it?

Nico


Herby Vojčík <[hidden email]> writes:

> Manfred Kröhnert wrote:
>> Hi,
>>
>> I think I might have found what lead to the following error:
>>
>> On Thu, Nov 1, 2012 at 4:12 PM, Manfred Kröhnert
>> <[hidden email] <mailto:[hidden email]>> wrote:
>>
>>     Hi everyone,
>>
>>     I am experiencing a strange problem with latest HEAD revision
>>     (d8439ae4a).
>>
>>     Here is some test code which used to work before
>>     SelectTest is a subclass of Widget.
>>
>>     SelectTest>>renderOn: html
>>        |select|
>>        select := html select with: [
>>          html option
>>            with: '--';
>>            value: 'abc'.
>>          html option
>>            with: '++';
>>            value: 'def'.
>>        ].
>>        select onChange: [:event |
>>          Transcript show: (select element); cr.
>>          Transcript show: (select element value); cr.
>>          Transcript show: (select element value value); cr.
>>        ].
>>
>>     Append this Widget to the body using
>>
>>     SelectTest new appendToJQuery: ('body' asJQuery)
>>
>>     The output is:
>>
>>     [object HTMLSelectElement]
>>     [object HTMLSelectElement]
>>     [object HTMLSelectElement]
>>
>>     However, at least the second line should produce a different output on
>>     the Transcript.
>>     Depending on the selected item it should either be 'abc' or 'def'.
>>
>>     If you do an inspect on (select element) there is definitely a 'value'
>>     property with the correct value.
>>     But inspecting (select element value) leads to the same inspector and
>>     not to the value object.
>>
>>     Any ideas?
>>
>>     Best,
>>     Manfred
>>
>>
>> Commit 85133ae99027d728a616f50f7cbcc88ba45c98d5 introduced the method
>> Object>>value which returns 'self'.
>> Since (select element) is of type Object the statement (select element
>> value) will always return 'self'.
>> This leads to the multiple output of [object HTMLSelectElement] since
>> each >>value message now answers self.
>>
>> The inspector on the other hand does not use the >>value message to
>> print the contents of the object and hence it displays the correct
>> string when selecting 'value'.
>>
>> Now the question is how to deal with this problem since most HTML seem
>> to have a member named 'value' and accessing it does not conform to the
>> rules on how to access object properties of non-Smalltalk objects.
>
> Either
>   1. learn to use attr: 'value', at: 'value', basicAt: 'value' etc. or
>   2. rewrite JSObjectProxy's value to try JS .value first
>
>> Best,
>> Manfred
>
> Herby
>
> --
> You received this message because you are subscribed to the Google Groups "amber-lang" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
Nicolas Petton
http://nicolas-petton.fr

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Strange behavior querying HTML <select> tag

sebastianconcept
we need to decide if it's the case of an inspector bug? 

is it the behavior rigth if no inspectors are involved? (I remember cases involving proxies and tools making weird stuff in other smalltalks)

sebastian

o/

On 20/02/2013, at 14:04, Manfred Kröhnert <[hidden email]> wrote:

Hi,

I can make a pull request to add a >>value method to JSObjectProxy which its able to handle this case.

The question is if this is a wanted addition and if make the same changes if other cases like this one appear.
Or, if we tell people accessing JS objecs through a proxy to always use >>at:.

Best,
Manfred

Am 20.02.2013 16:11 schrieb "Nicolas Petton" <[hidden email]>:

It can be quite inconvenient. That's the problem of using a
semi-transparent proxy. OTOH, it is consistent with Smalltalk.

Maybe JSObjectProxy >> value could handle this? Do you think it may be
worth it?

Nico


Herby Vojčík <[hidden email]> writes:

> Manfred Kröhnert wrote:
>> Hi,
>>
>> I think I might have found what lead to the following error:
>>
>> On Thu, Nov 1, 2012 at 4:12 PM, Manfred Kröhnert
>> <[hidden email] <mailto:[hidden email]>> wrote:
>>
>>     Hi everyone,
>>
>>     I am experiencing a strange problem with latest HEAD revision
>>     (d8439ae4a).
>>
>>     Here is some test code which used to work before
>>     SelectTest is a subclass of Widget.
>>
>>     SelectTest>>renderOn: html
>>        |select|
>>        select := html select with: [
>>          html option
>>            with: '--';
>>            value: 'abc'.
>>          html option
>>            with: '++';
>>            value: 'def'.
>>        ].
>>        select onChange: [:event |
>>          Transcript show: (select element); cr.
>>          Transcript show: (select element value); cr.
>>          Transcript show: (select element value value); cr.
>>        ].
>>
>>     Append this Widget to the body using
>>
>>     SelectTest new appendToJQuery: ('body' asJQuery)
>>
>>     The output is:
>>
>>     [object HTMLSelectElement]
>>     [object HTMLSelectElement]
>>     [object HTMLSelectElement]
>>
>>     However, at least the second line should produce a different output on
>>     the Transcript.
>>     Depending on the selected item it should either be 'abc' or 'def'.
>>
>>     If you do an inspect on (select element) there is definitely a 'value'
>>     property with the correct value.
>>     But inspecting (select element value) leads to the same inspector and
>>     not to the value object.
>>
>>     Any ideas?
>>
>>     Best,
>>     Manfred
>>
>>
>> Commit 85133ae99027d728a616f50f7cbcc88ba45c98d5 introduced the method
>> Object>>value which returns 'self'.
>> Since (select element) is of type Object the statement (select element
>> value) will always return 'self'.
>> This leads to the multiple output of [object HTMLSelectElement] since
>> each >>value message now answers self.
>>
>> The inspector on the other hand does not use the >>value message to
>> print the contents of the object and hence it displays the correct
>> string when selecting 'value'.
>>
>> Now the question is how to deal with this problem since most HTML seem
>> to have a member named 'value' and accessing it does not conform to the
>> rules on how to access object properties of non-Smalltalk objects.
>
> Either
>   1. learn to use attr: 'value', at: 'value', basicAt: 'value' etc. or
>   2. rewrite JSObjectProxy's value to try JS .value first
>
>> Best,
>> Manfred
>
> Herby
>
> --
> You received this message because you are subscribed to the Google Groups "amber-lang" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
Nicolas Petton
http://nicolas-petton.fr

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Strange behavior querying HTML <select> tag

Nicolas Petton
In reply to this post by Manfred Kröhnert

It's a complicated topic. The thing is that JSObjectProxy is not 100%
transparent. Usually in Pharo/Squeak similar proxies are made as
transparent as possible. So, I would vote for it.

Nico

Manfred Kröhnert <[hidden email]> writes:

> Hi,
>
> I can make a pull request to add a >>value method to JSObjectProxy which
> its able to handle this case.
>
> The question is if this is a wanted addition and if make the same changes
> if other cases like this one appear.
> Or, if we tell people accessing JS objecs through a proxy to always use
>>>at:.
>
> Best,
> Manfred
> Am 20.02.2013 16:11 schrieb "Nicolas Petton" <[hidden email]>:
>
>>
>> It can be quite inconvenient. That's the problem of using a
>> semi-transparent proxy. OTOH, it is consistent with Smalltalk.
>>
>> Maybe JSObjectProxy >> value could handle this? Do you think it may be
>> worth it?
>>
>> Nico
>>
>>
>> Herby Vojčík <[hidden email]> writes:
>>
>> > Manfred Kröhnert wrote:
>> >> Hi,
>> >>
>> >> I think I might have found what lead to the following error:
>> >>
>> >> On Thu, Nov 1, 2012 at 4:12 PM, Manfred Kröhnert
>> >> <[hidden email] <mailto:[hidden email]>>
>> wrote:
>> >>
>> >>     Hi everyone,
>> >>
>> >>     I am experiencing a strange problem with latest HEAD revision
>> >>     (d8439ae4a).
>> >>
>> >>     Here is some test code which used to work before
>> >>     SelectTest is a subclass of Widget.
>> >>
>> >>     SelectTest>>renderOn: html
>> >>        |select|
>> >>        select := html select with: [
>> >>          html option
>> >>            with: '--';
>> >>            value: 'abc'.
>> >>          html option
>> >>            with: '++';
>> >>            value: 'def'.
>> >>        ].
>> >>        select onChange: [:event |
>> >>          Transcript show: (select element); cr.
>> >>          Transcript show: (select element value); cr.
>> >>          Transcript show: (select element value value); cr.
>> >>        ].
>> >>
>> >>     Append this Widget to the body using
>> >>
>> >>     SelectTest new appendToJQuery: ('body' asJQuery)
>> >>
>> >>     The output is:
>> >>
>> >>     [object HTMLSelectElement]
>> >>     [object HTMLSelectElement]
>> >>     [object HTMLSelectElement]
>> >>
>> >>     However, at least the second line should produce a different output
>> on
>> >>     the Transcript.
>> >>     Depending on the selected item it should either be 'abc' or 'def'.
>> >>
>> >>     If you do an inspect on (select element) there is definitely a
>> 'value'
>> >>     property with the correct value.
>> >>     But inspecting (select element value) leads to the same inspector
>> and
>> >>     not to the value object.
>> >>
>> >>     Any ideas?
>> >>
>> >>     Best,
>> >>     Manfred
>> >>
>> >>
>> >> Commit 85133ae99027d728a616f50f7cbcc88ba45c98d5 introduced the method
>> >> Object>>value which returns 'self'.
>> >> Since (select element) is of type Object the statement (select element
>> >> value) will always return 'self'.
>> >> This leads to the multiple output of [object HTMLSelectElement] since
>> >> each >>value message now answers self.
>> >>
>> >> The inspector on the other hand does not use the >>value message to
>> >> print the contents of the object and hence it displays the correct
>> >> string when selecting 'value'.
>> >>
>> >> Now the question is how to deal with this problem since most HTML seem
>> >> to have a member named 'value' and accessing it does not conform to the
>> >> rules on how to access object properties of non-Smalltalk objects.
>> >
>> > Either
>> >   1. learn to use attr: 'value', at: 'value', basicAt: 'value' etc. or
>> >   2. rewrite JSObjectProxy's value to try JS .value first
>> >
>> >> Best,
>> >> Manfred
>> >
>> > Herby
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups "amber-lang" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> an email to [hidden email].
>> > For more options, visit https://groups.google.com/groups/opt_out.
>> >
>> >
>>
>> --
>> Nicolas Petton
>> http://nicolas-petton.fr
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "amber-lang" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [hidden email].
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups "amber-lang" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
Nicolas Petton
http://nicolas-petton.fr

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


Reply | Threaded
Open this post in threaded view
|

Re: Strange behavior querying HTML <select> tag

Manfred Kröhnert
Ok, here is the pull request:


Manfred

On Fri, Feb 22, 2013 at 3:17 PM, Nicolas Petton <[hidden email]> wrote:

It's a complicated topic. The thing is that JSObjectProxy is not 100%
transparent. Usually in Pharo/Squeak similar proxies are made as
transparent as possible. So, I would vote for it.

Nico

Manfred Kröhnert <[hidden email]> writes:

> Hi,
>
> I can make a pull request to add a >>value method to JSObjectProxy which
> its able to handle this case.
>
> The question is if this is a wanted addition and if make the same changes
> if other cases like this one appear.
> Or, if we tell people accessing JS objecs through a proxy to always use
>>>at:.
>
> Best,
> Manfred
> Am 20.02.2013 16:11 schrieb "Nicolas Petton" <[hidden email]>:
>
>>
>> It can be quite inconvenient. That's the problem of using a
>> semi-transparent proxy. OTOH, it is consistent with Smalltalk.
>>
>> Maybe JSObjectProxy >> value could handle this? Do you think it may be
>> worth it?
>>
>> Nico
>>
>>
>> Herby Vojčík <[hidden email]> writes:
>>
>> > Manfred Kröhnert wrote:
>> >> Hi,
>> >>
>> >> I think I might have found what lead to the following error:
>> >>
>> >> On Thu, Nov 1, 2012 at 4:12 PM, Manfred Kröhnert
>> >> <[hidden email] <mailto:[hidden email]>>
>> wrote:
>> >>
>> >>     Hi everyone,
>> >>
>> >>     I am experiencing a strange problem with latest HEAD revision
>> >>     (d8439ae4a).
>> >>
>> >>     Here is some test code which used to work before
>> >>     SelectTest is a subclass of Widget.
>> >>
>> >>     SelectTest>>renderOn: html
>> >>        |select|
>> >>        select := html select with: [
>> >>          html option
>> >>            with: '--';
>> >>            value: 'abc'.
>> >>          html option
>> >>            with: '++';
>> >>            value: 'def'.
>> >>        ].
>> >>        select onChange: [:event |
>> >>          Transcript show: (select element); cr.
>> >>          Transcript show: (select element value); cr.
>> >>          Transcript show: (select element value value); cr.
>> >>        ].
>> >>
>> >>     Append this Widget to the body using
>> >>
>> >>     SelectTest new appendToJQuery: ('body' asJQuery)
>> >>
>> >>     The output is:
>> >>
>> >>     [object HTMLSelectElement]
>> >>     [object HTMLSelectElement]
>> >>     [object HTMLSelectElement]
>> >>
>> >>     However, at least the second line should produce a different output
>> on
>> >>     the Transcript.
>> >>     Depending on the selected item it should either be 'abc' or 'def'.
>> >>
>> >>     If you do an inspect on (select element) there is definitely a
>> 'value'
>> >>     property with the correct value.
>> >>     But inspecting (select element value) leads to the same inspector
>> and
>> >>     not to the value object.
>> >>
>> >>     Any ideas?
>> >>
>> >>     Best,
>> >>     Manfred
>> >>
>> >>
>> >> Commit 85133ae99027d728a616f50f7cbcc88ba45c98d5 introduced the method
>> >> Object>>value which returns 'self'.
>> >> Since (select element) is of type Object the statement (select element
>> >> value) will always return 'self'.
>> >> This leads to the multiple output of [object HTMLSelectElement] since
>> >> each >>value message now answers self.
>> >>
>> >> The inspector on the other hand does not use the >>value message to
>> >> print the contents of the object and hence it displays the correct
>> >> string when selecting 'value'.
>> >>
>> >> Now the question is how to deal with this problem since most HTML seem
>> >> to have a member named 'value' and accessing it does not conform to the
>> >> rules on how to access object properties of non-Smalltalk objects.
>> >
>> > Either
>> >   1. learn to use attr: 'value', at: 'value', basicAt: 'value' etc. or
>> >   2. rewrite JSObjectProxy's value to try JS .value first
>> >
>> >> Best,
>> >> Manfred
>> >
>> > Herby
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups "amber-lang" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> an email to [hidden email].
>> > For more options, visit https://groups.google.com/groups/opt_out.
>> >
>> >
>>
>> --
>> Nicolas Petton
>> http://nicolas-petton.fr
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "amber-lang" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [hidden email].
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
> --
> You received this message because you are subscribed to the Google Groups "amber-lang" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
Nicolas Petton
http://nicolas-petton.fr

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply | Threaded
Open this post in threaded view
|

Re: Strange behavior querying HTML <select> tag

Manfred Kröhnert
In reply to this post by sebastianconcept
A patch has been integrated into master to address the problem with the >>value method on JSObjectProxy.

The Inspector was not at fault here since Object>>value was evaluated on JSObjectProxy before the JS property.

Best,
Manfred


On Fri, Feb 22, 2013 at 2:02 PM, sebastian <[hidden email]> wrote:
we need to decide if it's the case of an inspector bug? 

is it the behavior rigth if no inspectors are involved? (I remember cases involving proxies and tools making weird stuff in other smalltalks)

sebastian

o/

On 20/02/2013, at 14:04, Manfred Kröhnert <[hidden email]> wrote:

Hi,

I can make a pull request to add a >>value method to JSObjectProxy which its able to handle this case.

The question is if this is a wanted addition and if make the same changes if other cases like this one appear.
Or, if we tell people accessing JS objecs through a proxy to always use >>at:.

Best,
Manfred

Am 20.02.2013 16:11 schrieb "Nicolas Petton" <[hidden email][hidden email]>:

It can be quite inconvenient. That's the problem of using a
semi-transparent proxy. OTOH, it is consistent with Smalltalk.

Maybe JSObjectProxy >> value could handle this? Do you think it may be
worth it?

Nico


Herby Vojčík <[hidden email][hidden email]> writes:

> Manfred Kröhnert wrote:
>> Hi,
>>
>> I think I might have found what lead to the following error:
>>
>> On Thu, Nov 1, 2012 at 4:12 PM, Manfred Kröhnert
>> <[hidden email][hidden email] <mailto:[hidden email][hidden email]>> wrote:
>>
>>     Hi everyone,
>>
>>     I am experiencing a strange problem with latest HEAD revision
>>     (d8439ae4a).
>>
>>     Here is some test code which used to work before
>>     SelectTest is a subclass of Widget.
>>
>>     SelectTest>>renderOn: html
>>        |select|
>>        select := html select with: [
>>          html option
>>            with: '--';
>>            value: 'abc'.
>>          html option
>>            with: '++';
>>            value: 'def'.
>>        ].
>>        select onChange: [:event |
>>          Transcript show: (select element); cr.
>>          Transcript show: (select element value); cr.
>>          Transcript show: (select element value value); cr.
>>        ].
>>
>>     Append this Widget to the body using
>>
>>     SelectTest new appendToJQuery: ('body' asJQuery)
>>
>>     The output is:
>>
>>     [object HTMLSelectElement]
>>     [object HTMLSelectElement]
>>     [object HTMLSelectElement]
>>
>>     However, at least the second line should produce a different output on
>>     the Transcript.
>>     Depending on the selected item it should either be 'abc' or 'def'.
>>
>>     If you do an inspect on (select element) there is definitely a 'value'
>>     property with the correct value.
>>     But inspecting (select element value) leads to the same inspector and
>>     not to the value object.
>>
>>     Any ideas?
>>
>>     Best,
>>     Manfred
>>
>>
>> Commit 85133ae99027d728a616f50f7cbcc88ba45c98d5 introduced the method
>> Object>>value which returns 'self'.
>> Since (select element) is of type Object the statement (select element
>> value) will always return 'self'.
>> This leads to the multiple output of [object HTMLSelectElement] since
>> each >>value message now answers self.
>>
>> The inspector on the other hand does not use the >>value message to
>> print the contents of the object and hence it displays the correct
>> string when selecting 'value'.
>>
>> Now the question is how to deal with this problem since most HTML seem
>> to have a member named 'value' and accessing it does not conform to the
>> rules on how to access object properties of non-Smalltalk objects.
>
> Either
>   1. learn to use attr: 'value', at: 'value', basicAt: 'value' etc. or
>   2. rewrite JSObjectProxy's value to try JS .value first
>
>> Best,
>> Manfred
>
> Herby
>
> --
> You received this message because you are subscribed to the Google Groups "amber-lang" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email][hidden email].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

--
Nicolas Petton
http://nicolas-petton.fr

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email][hidden email].
For more options, visit https://groups.google.com/groups/opt_out.


--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.