Bug 14948 - What should getFlowByName return if there is no flow with the given name?
What should getFlowByName return if there is no flow with the given name?
Status: RESOLVED FIXED
Product: CSS
Classification: Unclassified
Component: Regions
unspecified
PC All
: P2 normal
: ---
Assigned To: Vincent Hardy
cssom
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-11-28 15:43 UTC by Vincent Hardy
Modified: 2012-04-11 21:06 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vincent Hardy 2011-11-28 15:43:34 UTC
Feedback from Mihnea-Vlad Ovidenie <mihnea@adobe.com> 

===
1. I have a document that does not have a flow thread. From js, I call document.getFlowByName(".."). I assume that this call returns a null object since I do not yet have a flow thread.

2. Another possibility would be to return a valid js object, that, in the future, if the user adds a flowThread with the desired name, gets connected to the flow thread.

Should we support 1 or 2? I would say 1 but the spec does not say anything about the lifetime of the NamedFlow objects.

===
Comment 1 Vincent Hardy 2012-03-13 22:29:01 UTC
So with option 1, we have:

// No flow yet
var nf = document.getFlowByName('article'); // nf is null

// Add content to 'article'
nf = document.getFlowByName('article'); // nf is not null

// Remove all content from 'article'

// nf is now a NamedFlow object that has no content.
nf === document.getFlowByName('article'); // evaluates to false..

Since we can have a named flow with no content, I think I would go with option 2:

// No flow yet
var nf = document.getFlowByName('article'); // nf is not null

// Add content to 'article'
nf === document.getFlowByName('article'); // evaluates to true

// Remove all content from 'article'

// nf is now a NamedFlow object that has no content.
nf === document.getFlowByName('article'); // evaluates to true..
Comment 2 Vincent Hardy 2012-03-22 16:30:58 UTC
(In reply to comment #1)
> So with option 1, we have:
> 
> // No flow yet
> var nf = document.getFlowByName('article'); // nf is null
> 
> // Add content to 'article'
> nf = document.getFlowByName('article'); // nf is not null
> 
> // Remove all content from 'article'
> 
> // nf is now a NamedFlow object that has no content.
> nf === document.getFlowByName('article'); // evaluates to false..
> 
> Since we can have a named flow with no content, I think I would go with option
> 2:
> 
> // No flow yet
> var nf = document.getFlowByName('article'); // nf is not null
> 
> // Add content to 'article'
> nf === document.getFlowByName('article'); // evaluates to true
> 
> // Remove all content from 'article'
> 
> // nf is now a NamedFlow object that has no content.
> nf === document.getFlowByName('article'); // evaluates to true..

After discussion:

Option 1 with the following precisions:

- if a flow has never been referenced by CSS or JS, return null.
- if a flow was previous created, but no longer exists, the implementation may return null.
- if a script holds on to a reference to a NamedFlow, implementations must guarantee that a) the object is valid (can be used) at all times, and b) subsequent calls to getFlowByName with the same name return the same object.
Comment 3 Vincent Hardy 2012-03-27 17:06:15 UTC
Changes for this issue:

https://dvcs.w3.org/hg/csswg/rev/d4e15f801ff5