Bug 16999 - Convert custom attributes to object properties
Summary: Convert custom attributes to object properties
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL: https://ibsbjstar.ccb.com.cn/app/V5/C...
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-24 16:19 PST by Rui Jiang
Modified: 2008-01-26 23:55 PST (History)
3 users (show)

See Also:


Attachments
test case (397 bytes, text/html)
2008-01-26 23:48 PST, Alexey Proskuryakov
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Rui Jiang 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>
Comment 1 Eric Seidel (no email) 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.
Comment 2 Geoffrey Garen 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.)
Comment 3 Rui Jiang 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
Comment 4 Dave Hyatt 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.

Comment 5 Alexey Proskuryakov 2008-01-26 23:48:59 PST
Created attachment 18716 [details]
test case

Same test as an attachment.
Comment 6 Alexey Proskuryakov 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.