You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@flex.apache.org by "Justin Mclean (JIRA)" <ji...@apache.org> on 2013/04/21 03:26:13 UTC
[jira] [Commented] (FLEX-24296) ListCollectionView should throw a
RangeError instead of Error when accessed with negative index via squared
brackets
[ https://issues.apache.org/jira/browse/FLEX-24296?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13637430#comment-13637430 ]
Justin Mclean commented on FLEX-24296:
--------------------------------------
Confirmed still an issue in Apache Flex 4.9.1
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" initialize="init()">
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.events.FlexEvent;
protected function init():void
{
var list:ArrayCollection = new ArrayCollection();
trace(list[-1]);
}
]]>
</fx:Script>
</s:Application>
> ListCollectionView should throw a RangeError instead of Error when accessed with negative index via squared brackets
> ---------------------------------------------------------------------------------------------------------------------
>
> Key: FLEX-24296
> URL: https://issues.apache.org/jira/browse/FLEX-24296
> Project: Apache Flex
> Issue Type: Bug
> Components: Collections
> Affects Versions: Adobe Flex SDK 3.5 (Release)
> Environment: Affected OS(s): All OS Platforms
> Affected OS(s): All OS Platforms
> Language Found: English
> Reporter: Adobe JIRA
> Labels: easyfix, easytest
>
> Steps to reproduce:
> 1. create a ListCollectionView or a subclass of it like ArrayCollection
> 2. access the collection with index -1.
>
> Actual Results:
> an error is thrown stating invalid property (e.g "invalid property: -1")
>
> Expected Results:
> a RangeError is thrown, like for positive invalid indices
> Note: The error has been seen in mx.controls.treeClasses.HierarchicalViewCursor which uses
> array like access but only catches range errors.
>
> Workaround (if any):
> Use getItemAt instead or modify ListCollectionView#getProperty
>
> override flash_proxy function getProperty(name:*):*
> {
> if (name is QName)
> name = name.localName;
> var index:int = -1;
> var isNumber:Boolean = false; //<= added
> try
> {
> // If caller passed in a number such as 5.5, it will be floored.
> var n:Number = parseInt(String(name));
> if (!isNaN(n)) {
> index = int(n);
> isNumber = true; //<= added
> }
> }
> catch(e:Error) // localName was not a number
> {
> }
> if (!isNumber) //<= changed
> {
> var message:String = resourceManager.getString(
> "collections", "unknownProperty", [ name ]);
> throw new Error(message);
> }
> else
> {
> return getItemAt(index); //will do the range checks
> }
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira