[Bug 16223] New: Change .readyState to use string values rather than numeric constants

https://www.w3.org/Bugs/Public/show_bug.cgi?id=16223

           Summary: Change .readyState to use string values rather than
                    numeric constants
           Product: WebAppsWG
           Version: unspecified
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: WebSocket API (editor: Ian Hickson)
        AssignedTo: ian@hixie.ch
        ReportedBy: jonas@sicking.cc
         QAContact: public-webapps-bugzilla@w3.org
                CC: mike@w3.org, public-webapps@w3.org


Numeric constants sucks when used in javascript. Code like

if (ws.readyState == WebSocket.CONNECTING) { ... }

is both harder to read and harder to type compared to

if (ws.readyState == "connecting") { ... }

All the uppercase letters are a pain to type and and stick out like a sore
thumb.

Additionally there's a very real risk that people will write code like

if (ws.readyState == 0) { ... }

since '0' is so much easier to write than 'WebSocket.CONNECTING'.

It's even likely that comparing to a string is faster than comparing to
WebSocket.CONNECTING since the latter involves a property lookup.

-- 
Configure bugmail: https://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

Received on Sunday, 4 March 2012 00:12:41 UTC