PDA

View Full Version : Ext alpha3-rev4: Bug in Ext.Element.update() ?



schmidetzki
18 Mar 2007, 2:59 AM
I get a JS-Error in line 3037 in ext_all_debug.js

The code is in onAvaliable():

var srcMatch = match[1].match(srcRe);

I patched it to

var srcMatch = match[0].match(srcRe); // WS: patch
... and it works now

(I looked in rev3: rev3 checks match[0]. Don't know why this was changed in rev4)

Animal
18 Mar 2007, 3:16 AM
Care to share the error? Or the code that produced it?

If you actually compared the two versions, you'd see a difference.

match[0] is the whole matched string, and we don't want to look for "src='foo'" in that because the <script> tag contents might have source code in which uses that (in en Ext.Template for example). So we extract the remainder of the <script> open tag after "<script" and up to ">" into capture group 1 - ie match[1] - and search in that.

It's a necessary change, and if there's an error, please post the conditions here, and let us take a look and fix it properly.

schmidetzki
18 Mar 2007, 8:58 AM
Care to share the error? Or the code that produced it?
Sure.



So we extract the remainder of the <script> open tag after "<script" and up to ">" into capture group 1 - ie match[1] - and search in that.


But mach[1] may not exist and throws the JS-error:


match[1] has no properties
http://localhost:8080/WGAPublisher/wga/js/ext-all-debug
Line 3037

You have to test for match[1] before using it

Here is my simple example:


<html>
<head>
// includes ...
</head>

<body>

<div id="el"></div>

<script>
var html="updated<scrip" + "t>alert('hallo')</scrip" + "t>";
var um=Ext.get("el").update(html, true);
</script>
</body>

</html>

Animal
18 Mar 2007, 9:27 AM
Ah yes, I had not thought of trying without the mandatory type attribute on my script tags. In the circumstances with the scripts being pulled and evaluated programatically rather than parsed as HTML, I suppose coding them to adhere to standards is pointless - might as well just be "<script>".

Jack should be able to fix this in the next release.

jack.slocum
19 Mar 2007, 5:34 AM
I am adding:

var srcMatch = match[1] ? match[1].match(srcRe) : false;

Does this fix the issue?

schmidetzki
19 Mar 2007, 10:52 AM
Does this fix the issue?
Yep.
No more JS-errors and everything seems to work perfect.