Re: [whatwg] Question regarding event: in server-sent events
Thanks for the clarifications, this helps a lot. -Nicholas __ Commander Lock: "Dammit Morpheus, not everyone believes what you believe!" Morpheus: "My beliefs do not require them to." -Original Message- From: Anne van Kesteren [mailto:ann...@opera.com] Sent: Tuesday, October 19, 2010 12:54 AM To: wha...@whatwg.org; Nicholas Zakas Subject: Re: [whatwg] Question regarding event: in server-sent events On Mon, 18 Oct 2010 19:38:46 +0200, Nicholas Zakas wrote: > Just for my own understanding, what you're saying is: > > 1) Any event name in the stream must be a valid event name in that it > must not have spaces, special characters, etc. (The wording in the spec > made me think that it must be an event name that is listed in the DOM > Events spec, such as click.) Yes, although it is not clear whether per the current DOM Events specification an event name with a space would be invalid. > 2) When you define an custom event name, this still fires the message > event with event.type set to the custom event name. Well, it dispatches an event that uses the MessageEvent interface. But e.g. a function attached to onmessage will not be invoked, as the event is not named message, but something else. So you need obj.addEventListener(customEvent, ...). -- Anne van Kesteren http://annevankesteren.nl/
Re: [whatwg] Question regarding event: in server-sent events
On Mon, 18 Oct 2010 19:38:46 +0200, Nicholas Zakas wrote: Just for my own understanding, what you're saying is: 1) Any event name in the stream must be a valid event name in that it must not have spaces, special characters, etc. (The wording in the spec made me think that it must be an event name that is listed in the DOM Events spec, such as click.) Yes, although it is not clear whether per the current DOM Events specification an event name with a space would be invalid. 2) When you define an custom event name, this still fires the message event with event.type set to the custom event name. Well, it dispatches an event that uses the MessageEvent interface. But e.g. a function attached to onmessage will not be invoked, as the event is not named message, but something else. So you need obj.addEventListener(customEvent, ...). -- Anne van Kesteren http://annevankesteren.nl/
Re: [whatwg] Question regarding event: in server-sent events
Just for my own understanding, what you're saying is: 1) Any event name in the stream must be a valid event name in that it must not have spaces, special characters, etc. (The wording in the spec made me think that it must be an event name that is listed in the DOM Events spec, such as click.) 2) When you define an custom event name, this still fires the message event with event.type set to the custom event name. Are those correct? -Nicholas __ Commander Lock: "Dammit Morpheus, not everyone believes what you believe!" Morpheus: "My beliefs do not require them to." -Original Message- From: Anne van Kesteren [mailto:ann...@opera.com] Sent: Friday, October 15, 2010 11:42 AM To: wha...@whatwg.org; Nicholas Zakas Subject: Re: [whatwg] Question regarding event: in server-sent events On Fri, 15 Oct 2010 20:34:14 +0200, Nicholas Zakas wrote: > In reading through the spec, it looks like this is legal in the event > stream: > > event: foo > data: bar > > And then processed as: > >>> If the event name buffer is not the empty string but is also not a >>> valid event type name, as defined by the DOM Events specification, set >>> the data buffer and the event name buffer to the empty string and >>> abort these steps. > > If I'm reading this correctly, an event name of "foo" would fail this > step in the process and not cause a message event to be fired. However, > if the event name were for example "click", then this would be okay and > the following step would be taken: "foo" is a valid event type name. This would only fail when Event.initEvent(event name buffer, ...) fails. It seems per the current draft of DOM Events that will be never so maybe this ought to be reworded some. But then DOM Events is not done yet so... > 3) Assuming I've understood the current spec correctly, what is > the use case for named events? To make dispatching to different parts of the code easier. Without having to create some kind of logic that parses the data first. -- Anne van Kesteren http://annevankesteren.nl/
Re: [whatwg] Question regarding event: in server-sent events
On Fri, 15 Oct 2010 20:34:14 +0200, Nicholas Zakas wrote: In reading through the spec, it looks like this is legal in the event stream: event: foo data: bar And then processed as: If the event name buffer is not the empty string but is also not a valid event type name, as defined by the DOM Events specification, set the data buffer and the event name buffer to the empty string and abort these steps. If I'm reading this correctly, an event name of "foo" would fail this step in the process and not cause a message event to be fired. However, if the event name were for example "click", then this would be okay and the following step would be taken: "foo" is a valid event type name. This would only fail when Event.initEvent(event name buffer, ...) fails. It seems per the current draft of DOM Events that will be never so maybe this ought to be reworded some. But then DOM Events is not done yet so... 3) Assuming I've understood the current spec correctly, what is the use case for named events? To make dispatching to different parts of the code easier. Without having to create some kind of logic that parses the data first. -- Anne van Kesteren http://annevankesteren.nl/
[whatwg] Question regarding event: in server-sent events
In reading through the spec, it looks like this is legal in the event stream: event: foo data: bar And then processed as: >> If the event name buffer is not the empty string but is also not a valid >> event type name, as defined by the DOM Events specification, set the data >> buffer and the event name buffer to the empty string and abort these steps. If I'm reading this correctly, an event name of "foo" would fail this step in the process and not cause a message event to be fired. However, if the event name were for example "click", then this would be okay and the following step would be taken: >>If the event name buffer has a value other than the empty string, change the >>type of the newly created event to equal the value of the event name buffer. A few questions about this: 1) Does this mean that a click event would be fired on the EventSource object, such as that onclick would be called? Or does this still fire the message event but event.type is now "click"? 2) Why the limitation of events only in the DOM Events spec? It seems that most of those events are irrelevant in the context of a non-UI part of the page. 3) Assuming I've understood the current spec correctly, what is the use case for named events? Thanks, Nicholas