You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ha...@apache.org on 2021/11/12 09:52:53 UTC
[royale-asjs] branch develop updated: Fixed copying empty attributes
This is an automated email from the ASF dual-hosted git repository.
harbs pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
The following commit(s) were added to refs/heads/develop by this push:
new 8d457e9 Fixed copying empty attributes
8d457e9 is described below
commit 8d457e97344a315d11fe3f605d5567b5787faf8e
Author: Harbs <ha...@in-tools.com>
AuthorDate: Fri Nov 12 11:52:39 2021 +0200
Fixed copying empty attributes
---
frameworks/projects/XML/src/main/royale/XML.as | 12 +++++++++---
.../test/royale/flexUnitTests/xml/XMLTesterStringifyTest.as | 9 +++++++++
2 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/frameworks/projects/XML/src/main/royale/XML.as b/frameworks/projects/XML/src/main/royale/XML.as
index 6bf3135..1ebc43e 100644
--- a/frameworks/projects/XML/src/main/royale/XML.as
+++ b/frameworks/projects/XML/src/main/royale/XML.as
@@ -274,8 +274,11 @@ package
*/
static public var recursiveNotify:Boolean = false;
- static private function escapeAttributeValue(value:String):String
+ static private function escapeAttributeValue(value:*):String
{
+ if(value === undefined){
+ return "";
+ }
var arr:Array = String(value).split("");
var len:int = arr.length;
for(var i:int=0;i<len;i++)
@@ -3028,9 +3031,12 @@ package
// text, comment, processing-instruction, attribute, or element
var kind:String = getNodeRef();
if( kind == ATTRIBUTE)
- return _value;
+ return _value == null ? "" : _value;
if(kind == TEXT)
- return _value && _value.indexOf('<![CDATA[') == 0 ? _value.substring(9, _value.length-3): _value;
+ {
+ var textVal:String = _value == null ? "" : _value;
+ return textVal.indexOf('<![CDATA[') == 0 ? textVal.substring(9, textVal.length-3): textVal;
+ }
if(kind == COMMENT)
return "";
if(kind == PROCESSING_INSTRUCTION)
diff --git a/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterStringifyTest.as b/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterStringifyTest.as
index 032cfe6..b587c18 100644
--- a/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterStringifyTest.as
+++ b/frameworks/projects/XML/src/test/royale/flexUnitTests/xml/XMLTesterStringifyTest.as
@@ -316,6 +316,15 @@ package flexUnitTests.xml
'<script><![CDATA[private function onStylesLoaded(ev:Event):void {currentState = "normal";facade = ApplicationFacade.getInstance();facade.notifyObservers(new Notification(ApplicationFacade.CMD_STARTUP, this));} ]]></script>',
script.toXMLString(), 'unexpected toXMLString with child CDATA')
}
+
+ [Test]
+ public function copyTest():void{
+ // make sure empty atributes are preserved.
+ var xml:XML = <foo baz=""/>;
+ assertEquals(xml.toXMLString(),'<foo baz=""/>',"unexpected to XMLString with empty attribute");
+ var xml2:XML = xml.copy();
+ assertEquals(xml2.toXMLString(),'<foo baz=""/>',"unexpected to XMLString with empty attribute after copy");
+ }
[Test]
[TestVariance(variance="JS",description="Some browsers (IE11/Edge legacy) can parse to a different order of attributes and namespace declarations (which affects stringified content comparisons)")]