Bug 50125 - can't define value getter on input element
Summary: can't define value getter on input element
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac (Intel) OS X 10.6
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-27 09:37 PST by Andreas Madsen
Modified: 2022-07-29 18:05 PDT (History)
6 users (show)

See Also:


Attachments
testcase (584 bytes, text/html)
2010-11-27 09:37 PST, Andreas Madsen
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Madsen 2010-11-27 09:37:41 PST
Created attachment 74962 [details]
testcase

I all browser, except Safari Webkit, i am able to manipulate the input.value with __defineGetter__.

There is no error, the function there is set in defineGetter will just never run.

Test case:
_______________________________________
<input type="text" value="2" id="input">

<script type="text/javascript">
    
    var input = document.getElementById('input');
    	
    	input.__defineGetter__('value', function () {
    		return parseInt(this.getAttribute('value')) * 2;
    	});
    	
    	console.log(input.value);
    	
    	if (input.value == 4) {
    		input.style.background = "#0F0";
    	} else {
    		input.style.background = "#F00";
    	}
</script>
_______________________________________

In this testcase safari webkit return 2, in all other browsers it return 4.
Comment 1 Alexey Proskuryakov 2010-11-27 17:01:55 PST
This is probably a known issue, but I'm not sure what to dupe to. See also: bug 26760.
Comment 2 Andreas Madsen 2010-11-28 03:30:48 PST
(In reply to comment #1)
> This is probably a known issue, but I'm not sure what to dupe to. See also: bug 26760.

I don't think is the same issue, the reason why it don't work is because input.value is a native value (if you understand what i mean).

If the testcase was for input.id or input.style i still won't work. But if I try input.test there is no problem because it not defined in the browser by default. As i know  Function.prototype.displayName is not a default property/value.

But it is possible that the source problem is the same in the two bugs (50125, 26760).
Comment 3 Oliver Hunt 2010-11-28 18:47:50 PST
This is a duplicate of the bug that needs us to expose DOM attributes as getters/setters at the appropriate level of the prototype chain.
Comment 4 Ahmad Saleem 2022-07-29 17:07:20 PDT
I am unable to reproduce this bug since now all browsers have same results and show "2" with green background in <input> field and it matches with Chrome Canary 106, Firefox Nightly 105 and Safari 15.6 on macOS 12.5. I think this can be marked as "RESOLVED CONFIGURATION CHANGED" or "RESOLVED INVALID" (latter since other browsers changed their behavior as per Comment 0). Thanks!
Comment 5 Brent Fulgham 2022-07-29 18:05:25 PDT
Sounds good. Thank you for testing!