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

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

           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: Server-Sent Events (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 (es.readyState == EventSource.CONNECTING) { ... }

is both harder to read and harder to type compared to

if (es.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 'EventSource.CONNECTING'.

It's even likely that comparing to a string is faster than comparing to
EventSource.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:14:19 UTC