Make WordPress Core

Changeset 35708


Ignore:
Timestamp:
11/19/2015 11:05:39 PM (11 years ago)
Author:
pento
Message:

Embeds: Remove & characters from the inline embed JS.

Older versions of WordPress will convert those & characters to &, which makes for some non-functional JS. If folks are running an older release, let's not make their lives more difficult than it already is.

Props pento, peterwilsoncc.

See #34698.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Gruntfile.js

    r35684 r35708  
    436436                                        '!wp-includes/js/swfobject.js',
    437437                                        '!wp-includes/js/underscore.*',
    438                                         '!wp-includes/js/zxcvbn.min.js'
    439                                 ]
     438                                        '!wp-includes/js/zxcvbn.min.js',
     439                                        '!wp-includes/js/wp-embed.js' // We have extra options for this, see uglify:embed
     440                                ]
     441                        },
     442                        embed: {
     443                                options: {
     444                                        compress: {
     445                                                conditionals: false
     446                                        }
     447                                },
     448                                expand: true,
     449                                cwd: SOURCE_DIR,
     450                                dest: BUILD_DIR,
     451                                ext: '.min.js',
     452                                src: ['wp-includes/js/wp-embed.js']
    440453                        },
    441454                        media: {
    … …  
    648661                'cssmin:colors',
    649662                'uglify:core',
     663                'uglify:embed',
    650664                'uglify:jqueryui',
    651665                'concat:tinymce',
  • trunk/src/wp-includes/js/wp-embed.js

    r35577 r35708  
    22        'use strict';
    33
    4         var supportedBrowser = ( document.querySelector && window.addEventListener ),
     4        var supportedBrowser = false,
    55                loaded = false;
     6
     7                if ( document.querySelector ) {
     8                        if ( window.addEventListener ) {
     9                                supportedBrowser = true;
     10                        }
     11                }
    612
    713        window.wp = window.wp || {};
    … …  
    5157
    5258                                /* Only continue if link hostname matches iframe's hostname. */
    53                                 if ( targetURL.host === sourceURL.host && document.activeElement === source ) {
    54                                         window.top.location.href = data.value;
     59                                if ( targetURL.host === sourceURL.host ) {
     60                                        if ( document.activeElement === source ) {
     61                                                window.top.location.href = data.value;
     62                                        }
    5563                                }
    5664                        }
    … …  
    7886                        source.style.display = '';
    7987
    80                         if ( !source.getAttribute( 'data-secret' ) ) {
    81                                 /* Add secret to iframe */
    82                                 secret = Math.random().toString( 36 ).substr( 2, 10 );
    83                                 source.src += '#?secret=' + secret;
    84                                 source.setAttribute( 'data-secret', secret );
     88                        if ( source.getAttribute( 'data-secret' ) ) {
     89                                continue;
    8590                        }
    8691
     92                        /* Add secret to iframe */
     93                        secret = Math.random().toString( 36 ).substr( 2, 10 );
     94                        source.src += '#?secret=' + secret;
     95                        source.setAttribute( 'data-secret', secret );
     96
    8797                        /* Remove security attribute from iframes in IE10 and IE11. */
    88                         if ( ( isIE10 || isIE11 ) && !!source.getAttribute( 'security' ) ) {
     98                        if ( ( isIE10 || isIE11 ) ) {
    8999                                iframeClone = source.cloneNode( true );
    90100                                iframeClone.removeAttribute( 'security' );
Note: See TracChangeset for help on using the changeset viewer.