1. #1
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,496
    Vote Rating
    44
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default Element.update() and loadScripts...

    Element.update() and loadScripts...


    Turned out the regex still wasn't there. It was greedy in matching the ([\'\"]) pattern, and in the string <script src="foo" type="text/javascript"></script> if would extract the source as 'foo" type="text/javascript"'

    Also, on the else side of the srcMatch, match[1] is always true for valid script tags - it's a string, but zero length, so I added a length check:

    Code:
            YAHOO.util.Event.onAvailable(id, function(){
                var hd = document.getElementsByTagName("head")[0];
                var re = /(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/img; 
                var srcRe = /\ssrc=[\'\"]([^\'\"]*)[\'\"]/i; // <------ this changed
                var match;
                while(match = re.exec(html)){
                    var srcMatch = match[0].match(srcRe);
                    if(srcMatch && srcMatch[1]){
                       var s0 = document.createElement("script");
                       s0.src = srcMatch[1];
                       hd.appendChild(s0);
                    }else if(match[1] && (match[1].length != 0)){ //<----- this changed too
                       eval(match[1]);
                    }                     
                }
                var el = document.getElementById(id);
                if(el){el.parentNode.removeChild(el);}
                if(typeof callback == 'function'){
                    callback();
                }
            });

  2. #2
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    16
    jack.slocum will become famous soon enough

      0  

    Default


    Damn, I wish I would have found these before the release. That sucks.

  3. #3
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,496
    Vote Rating
    44
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    Well, I guess I should have tested with the src and type attributes the other way round when I did my initial testing too!

  4. #4
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,496
    Vote Rating
    44
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    In fact, the regex to extract the src should be

    Code:
    /\ssrc=([\'\"])(.*?)\1/i
    The "?" after the .* makes it reluctant rather than greedy, so it stops at the first occurrence of capture group 1 (' or ").

    Obviously then, the src is in match[2]

  5. #5
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    16
    jack.slocum will become famous soon enough

      0  

    Default


    I'm ahead of ya. I didn't use the back reference but using it makes sense.

  6. #6
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,496
    Vote Rating
    44
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    In fact using the backreference method to delimit the src="" string, I'm sure you could get the script search for both src URLs and source code content back into one regex! Hours of fun for the geekly minded........ I'll have a play! :lol:

  7. #7
    Ext User
    Join Date
    Mar 2007
    Location
    Sweden
    Posts
    50
    Vote Rating
    0
    young_matthewd is on a distinguished road

      0  

    Default fix hasn't made it into 33-rc3?

    fix hasn't made it into 33-rc3?


    ran into the same problem. wondering if the fix will make it's way into the rc4 or final 33 release? currently using rc3. thanks / matthew

  8. #8
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,496
    Vote Rating
    44
    Animal has a spectacular aura about Animal has a spectacular aura about Animal has a spectacular aura about

      0  

    Default


    I'm not seeing the problem in RC3

  9. #9
    Ext User
    Join Date
    Mar 2007
    Location
    Sweden
    Posts
    50
    Vote Rating
    0
    young_matthewd is on a distinguished road

      0  

    Default regular expression switched but have to pull srcMatch[2]

    regular expression switched but have to pull srcMatch[2]


    hej,

    saw that the regular expression for srcRe was replaced between rc2 and rc3 but the src property gets set to blank if the srcMatch[1] item is pulled. had to pull srcMatch[2] instead (regardless of the order of script tag attributes).

  10. #10
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    16
    jack.slocum will become famous soon enough

      0  

    Default


    It should be 2, the 1st match is the quote. I will be doing a bug fix release to correct this and other rc3 bugs this weekend.

Similar Threads

  1. Element.update() && styles
    By vtswingkid in forum Ext 1.x: Bugs
    Replies: 11
    Last Post: 21 Jun 2007, 5:29 AM
  2. Element.update()
    By Animal in forum Ext 1.x: Bugs
    Replies: 1
    Last Post: 23 Oct 2006, 12:59 PM

Thread Participants: 3