RESOLVED WONTFIX16999
Convert custom attributes to object properties
https://bugs.webkit.org/show_bug.cgi?id=16999
Summary Convert custom attributes to object properties
Rui Jiang
Reported 2008-01-24 16:19:59 PST
To repro, goto: https://ibsbjstar.ccb.com.cn/app/V5/CN/STY1/login.jsp If the above link is invalid, goto http://www.ccb.com and try to find the login link. This is the top 3 bank in China and I use it a lot. Type in something in the input boxes, click the red button to login. There will be an alert box saying that: "user id has undefined minLength attribute". Look at the source of the page we can see that all the input has something like: <INPUT maxLength=20 name=USERID minLength="1" ...> Here minLength is not a standard attribute. Then in their JS, they do: if( (typeof fm[i].minLength) == "undefined" || fm[i].minLength == "" ){ alert("blahblah"); fm[i].focus(); return false; } fm[i] is child of the form, here it would be the input element. Clearly they add some custom attributes and use that as a way to store extra information. However they access it directly in JS like a property. This is supported in IE, but not in FF. More info: JS is at https://ibsbjstar.ccb.com.cn/V5/js5/ccblogin.js And the frame source contains the input form is at: https://ibsbjstar.ccb.com.cn/app/B2CMainPlatV5?CCB_IBSVersion=V5&CUSTYPE=0&TXCODE=CLOGIN&USERID=&DESKTOP=0&EXIT_PAGE=login.jsp REDUCED test case (try it in IE and Safari) <html><head></head><body> <h1>Unknown attributes</h1> <input id=userid type=text size=20 minLength=1 bizar="NO SUCH ATTR" maxLength=10 title="User name"></input> <div id="result"/> <script> var s = ""; s += "maxLength: " + userid.maxLength + "<br>"; s += "minLength: " + userid.minLength + "<br>"; var elm = document.getElementById("result"); elm.innerHTML = s; </script> </body></html>
Attachments
test case (397 bytes, text/html)
2008-01-26 23:48 PST, Alexey Proskuryakov
no flags
Eric Seidel (no email)
Comment 1 2008-01-24 16:31:28 PST
The interesting question is if IE does this for all custom attributes (mapping them to editable? properties on JS objects). I don't think we could ever implement this in WebKit, except as some sort of Quirks mode.
Geoffrey Garen
Comment 2 2008-01-24 16:56:12 PST
FYI, WebKit had a mini version of this feature before, but we intentionally removed it for the sake of standards conformance. (I'm not trying to say it's out of the question -- just that the question has been raised and answered before.)
Rui Jiang
Comment 3 2008-01-24 20:56:40 PST
(In reply to comment #1) > The interesting question is if IE does this for all custom attributes (mapping > them to editable? properties on JS objects). > > I don't think we could ever implement this in WebKit, except as some sort of > Quirks mode. > Yes, IE does this for all attributes that it doesn't recognize, and they are editable and you can still use getAttribute to query updated value: s += "getAttribute(\"minLength\"): " + userid.getAttribute("minLength") + "<br>"; userid.minLength = 99; s += "getAttribute(\"minLength\"): " + userid.getAttribute("minLength") + "<br>"; In IE, output is: getAttribute("minLength"): 1 getAttribute("minLength"): 99
Dave Hyatt
Comment 4 2008-01-25 13:18:25 PST
Yes, I believe we even used to support this and took it out. It caused lots of problems. I don't think we plan to do this ever, but I'll defer to someone more expert in this area like Geoff or Maciej.
Alexey Proskuryakov
Comment 5 2008-01-26 23:48:59 PST
Created attachment 18716 [details] test case Same test as an attachment.
Alexey Proskuryakov
Comment 6 2008-01-26 23:55:26 PST
(In reply to comment #4) > Yes, I believe we even used to support this and took it out. It caused lots of > problems. I don't think we plan to do this ever, but I'll defer to someone > more expert in this area like Geoff or Maciej. Do you remember what the problem were? This sounds like an important enough site to fix it if at all possible.
Ahmad Saleem
Comment 7 2022-08-11 09:49:04 PDT
I modified this test case slightly and added JS to using getAttribute to extract output of these custom attributes and it is working as intended: https://jsfiddle.net/ns5rk4ha/3/show All browsers (Chrome Canary 106, Firefox Nightly 105 and Safari 15.6 on macOS 12.6) show values of custom contributes. I am marking this as "RESOLVED CONFIGURATION CHANGED", please reopen, if my test case is different compared to test case attached or the issue in this bug is about. Thanks!
Alexey Proskuryakov
Comment 8 2022-08-19 18:22:46 PDT
Making properties out of unknown attributes is a not a thing, and at this point, this is WONTFIX. The reason why this test passes is misleading - minLength and maxLength are now actual real <input> attributes.
Note You need to log in before you can comment on or make changes to this bug.