سؤال

I have a process running in between my Webserver and the external world which does some changes on the traffic delivered by the Web Server. This is a 3rd party process. Other than other stuff done by this process, it also adds some tags lines to the pages delivered by the Webserver. As per the 3rd party, these tags are not standard HTML tags and will hence be ignored by the browser.

Assume the original lines are

<script type="text/javascript"> 

    var a = true;
    function whatever() 
    {
        if(a)
           return true;
    }
</script>

Then after passing through the filter, the lines may get transformed into

<script type="text/javascript"> 

<XYZ MY TAG>
    var a = true;
</XYZ>
    function whatever() 
    {
        if(a)
           return true;
    }
</script>

Now if the XYZ tag is not recognized by the browser/javascript engine in the Browser, does the standard say what it will do? As per the 3rd party who supplied this process, the behaviour will be the same before and after the transformation.

I am looking for some reference in the standard documents which say that this is true for

  1. Plain HTML
  2. Javascript in JS files
  3. Embedded Javascript in HTML Files.

Can anyone help? I have done some basic testing with IE & Chromium and it seems OK.

هل كانت مفيدة؟

المحلول

Plain HTML

It won't be ignored. It will be added to the DOM as an unknown element. (spec).

JavaScript

JavaScript is not HTML. It will be parsed as if it was JavaScript. Since it isn't valid, it will throw an exception.

HTML Script tags

Since it is after a <script> tag, before a </script> tag and is a "tag" that isn't </script>: the HTML parser does not treat it as a tag and passes it through to the JavaScript engine. (spec)

Since it is not valid JS, the JS engine will throw an exception.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top