Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,341
    Thanks
    260
    Thanked 32 Times in 31 Posts

    function not validating due to &&

    Trying to get this to pass W3C validation.

    The problem is the two & it does not like them and i tried
    && but then the code bombs.


    PHP Code:

    function bundleFunction(contextfuncargs
    {
      
    context context || null;
      if(
    typeof func == "string" && context)
        
    func context[func];
      if(!
    args)
        
    args = [];
      else if(!(
    args instanceof Array))
        
    args = [args];
      return function() {
        return 
    func.apply(contextargs);
      }
    }
    //close function bundleFunction 
    Any suggestions thanks
    Last edited by durangod; 01-01-2013 at 04:07 PM.

  • #2
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,341
    Thanks
    260
    Thanked 32 Times in 31 Posts
    Well i did get it to validate but i had to totally remove the && entirely. I tried wrapping in () as well as other attemps but encase them but no good. I have never seen that happen before.

    So this is the new code, it does seem to work but hope i didnt mess it up lol

    PHP Code:

    function bundleFunction(contextfuncargs
    {
      
    context context || null;
      if(
    typeof func == "string")
      {
        if(
    context)
        {
        
    func context[func];
        }
    //close if
      
    }//close if

      
    if(!args)
      {
       
    args = [];
         }else if(!(
    args instanceof Array))
           {
          
    args = [args];
           }

        return function() 
         {
         return 
    func.apply(contextargs);
         }

    }
    //close function bundleFunction 

  • #3
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,467
    Thanks
    3
    Thanked 495 Times in 482 Posts
    I validate your original using http://validator.w3.org/check and it was fine

    What DOC type are you using?
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #4
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,479
    Thanks
    6
    Thanked 981 Times in 954 Posts
    Yeah, sounds like you’re using XHTML. In that case you need to declare your JS as character data (CDATA), otherwise the parser thinks it’s still HTML.
    Code:
    <script type="text/javascript">
    // <![CDATA[
    … your code here …
    // ]]>
    </script>
    The best, however, is to have unobtrusive JS in a separate file which you just reference in the head using the src attribute.

  • Users who have thanked VIPStephan for this post:

    durangod (01-01-2013)

  • #5
    Senior Coder
    Join Date
    Nov 2010
    Posts
    1,341
    Thanks
    260
    Thanked 32 Times in 31 Posts
    Quote Originally Posted by vwphillips View Post
    I validate your original using http://validator.w3.org/check and it was fine

    What DOC type are you using?
    Code:
    <?xml version="1.0" encoding="iso-8859-1"?> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" lang="EN">


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •