apache / royale-compiler

Apache Royale Compiler
https://royale.apache.org/
Apache License 2.0
95 stars 49 forks source link

CDATA literal text error due to Data Binding, and newlines lost #213

Closed estanglerbm closed 1 year ago

estanglerbm commented 2 years ago

When using CDATA for literals that contain something that looks like data binding (i.e. {sum}), getting error:

Warning: Data binding will not be able to detect assignments to 'sum'.

Also (if you replace the problematic part with normal text), newlines are being lost (Flex preserves them).

TestLiteralsFlex.mxml.txt TestLiterals.mxml.txt

joshtynjala commented 1 year ago

I fixed the compiler issue where it incorrectly detected { and } as data binding inside CDATA. The missing new lines are because the MX TextArea component in Royale has [CollapseWhiteSpace] metadata on the text property. If you think that's wrong, it'll need to be handled on the royale-asjs side. The compiler is handling [CollapseWhiteSpace] correctly.

https://github.com/apache/royale-asjs/blob/apache-royale-0.9.9/frameworks/projects/MXRoyale/src/main/royale/mx/controls/TextArea.as#L1697

joshtynjala commented 1 year ago

Hmmm... actually, MX TextArea in the Flex SDK also has [CollapseWhiteSpace].

https://github.com/apache/flex-sdk/blob/apache-flex-sdk-4.16.1/frameworks/projects/mx/src/mx/controls/TextArea.as#L1733

So it looks like whitespace is collapsed except when it is contained within CData.