Is this expected behaviour in append?

Is this expected behaviour in append?

I think it is expected, but post here just in case...
I am getting an error when using append. If I am appending data with an ampersand it errors. However, it doesn't do this all the time. The error is on line 6325 of jquery.js, when the data is passed to innerHTML.
If the mimetype of the page is text/html, the data is xml escaped automatically. If the mimetype is application/xhtml+xml, it doesn't and gives an error. I have some sample code below. Unfortunately it doesn't give an error in the console like my live app. It does work with a mimetype of text/html and doesn't with application/xhtml+xml.


  1. <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta charset="utf-8"></meta>
        <title>dialog demo</title>
        <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css"></link>
        <script src="http://code.jquery.com/jquery-1.8.3.js"></script>
        <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
        <script type="text/javascript">
        function create_dialog ( ) {

            $('#dialog').dialog({ autoOpen: true, modal: true, open: foo, height: 400 });

            function foo() {
                $('#dialog').append('<div>' + 'A&amp;E' + '</div>');
            }; // foo

        }
        </script>
    </head>
    <body>
    <div id="dialog" title="foo">
    </div>
    <button id="opener" onclick="create_dialog()">open the dialog</button>
    </body>
    </html>