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: [email protected]
        ReportedBy: [email protected]
         QAContact: [email protected]
                CC: [email protected], [email protected]


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.

Reply via email to