Customize: Opt to disable IE8 support via conditional comments instead of using unreliable `Array.prototype.indexOf` feature detection.

Deprecate/remove `WP_Customize_Manager::customize_preview_html5()` and remove `document.head` polyfill, both of which were only in place for IE8 support.

Props ryankienstra, westonruter.
Fixes #38021.

Built from https://develop.svn.wordpress.org/trunk@38649


git-svn-id: http://core.svn.wordpress.org/trunk@38592 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2016-09-25 04:35:32 +00:00
parent 9fe024cd3f
commit 76681c40e3
5 changed files with 26 additions and 31 deletions

View File

@ -740,7 +740,6 @@ final class WP_Customize_Manager {
wp_enqueue_script( 'customize-preview' ); wp_enqueue_script( 'customize-preview' );
add_action( 'wp', array( $this, 'customize_preview_override_404_status' ) ); add_action( 'wp', array( $this, 'customize_preview_override_404_status' ) );
add_action( 'wp_head', array( $this, 'customize_preview_base' ) ); add_action( 'wp_head', array( $this, 'customize_preview_base' ) );
add_action( 'wp_head', array( $this, 'customize_preview_html5' ) );
add_action( 'wp_head', array( $this, 'customize_preview_loading_style' ) ); add_action( 'wp_head', array( $this, 'customize_preview_loading_style' ) );
add_action( 'wp_footer', array( $this, 'customize_preview_settings' ), 20 ); add_action( 'wp_footer', array( $this, 'customize_preview_settings' ), 20 );
add_action( 'shutdown', array( $this, 'customize_preview_signature' ), 1000 ); add_action( 'shutdown', array( $this, 'customize_preview_signature' ), 1000 );
@ -787,18 +786,10 @@ final class WP_Customize_Manager {
* Print a workaround to handle HTML5 tags in IE < 9. * Print a workaround to handle HTML5 tags in IE < 9.
* *
* @since 3.4.0 * @since 3.4.0
* @deprecated 4.7.0 Customizer no longer supports IE8, so all supported browsers recognize HTML5.
*/ */
public function customize_preview_html5() { ?> public function customize_preview_html5() {
<!--[if lt IE 9]> _deprecated_function( __FUNCTION__, '4.7.0' );
<script type="text/javascript">
var e = [ 'abbr', 'article', 'aside', 'audio', 'canvas', 'datalist', 'details',
'figure', 'footer', 'header', 'hgroup', 'mark', 'menu', 'meter', 'nav',
'output', 'progress', 'section', 'time', 'video' ];
for ( var i = 0; i < e.length; i++ ) {
document.createElement( e[i] );
}
</script>
<![endif]--><?php
} }
/** /**

View File

@ -745,11 +745,6 @@ wp.customize.selectiveRefresh = ( function( $, api ) {
api.bind( 'preview-ready', function() { api.bind( 'preview-ready', function() {
var handleSettingChange, watchSettingChange, unwatchSettingChange; var handleSettingChange, watchSettingChange, unwatchSettingChange;
// Polyfill for IE8 to support the document.head attribute.
if ( ! document.head ) {
document.head = $( 'head:first' )[0];
}
_.extend( self.data, _customizePartialRefreshExports ); _.extend( self.data, _customizePartialRefreshExports );
// Create the partial JS models. // Create the partial JS models.

File diff suppressed because one or more lines are too long

View File

@ -2151,6 +2151,7 @@ function wp_customize_url( $stylesheet = null ) {
* to the body tag by default. * to the body tag by default.
* *
* @since 3.4.0 * @since 3.4.0
* @since 4.7.0 Support for IE8 and below is explicitly removed via conditional comments.
*/ */
function wp_customize_support_script() { function wp_customize_support_script() {
$admin_origin = parse_url( admin_url() ); $admin_origin = parse_url( admin_url() );
@ -2158,20 +2159,28 @@ function wp_customize_support_script() {
$cross_domain = ( strtolower( $admin_origin[ 'host' ] ) != strtolower( $home_origin[ 'host' ] ) ); $cross_domain = ( strtolower( $admin_origin[ 'host' ] ) != strtolower( $home_origin[ 'host' ] ) );
?> ?>
<script type="text/javascript"> <!--[if lte IE 8]>
(function() { <script type="text/javascript">
var request, b = document.body, c = 'className', cs = 'customize-support', rcs = new RegExp('(^|\\s+)(no-)?'+cs+'(\\s+|$)'); document.body.className = document.body.className.replace( /(^|\s)(no-)?customize-support(?=\s|$)/, '' ) + ' no-customize-support';
</script>
<![endif]-->
<!--[if gte IE 9]><!-->
<script type="text/javascript">
(function() {
var request, b = document.body, c = 'className', cs = 'customize-support', rcs = new RegExp('(^|\\s+)(no-)?'+cs+'(\\s+|$)');
<?php if ( $cross_domain ): ?> <?php if ( $cross_domain ) : ?>
request = (function(){ var xhr = new XMLHttpRequest(); return ('withCredentials' in xhr); })(); request = (function(){ var xhr = new XMLHttpRequest(); return ('withCredentials' in xhr); })();
<?php else: ?> <?php else : ?>
request = true; request = true;
<?php endif; ?> <?php endif; ?>
b[c] = b[c].replace( rcs, ' ' ); b[c] = b[c].replace( rcs, ' ' );
b[c] += ( window.postMessage && request && Array.prototype.indexOf ? ' ' : ' no-' ) + cs; // The customizer requires postMessage and CORS (if the site is cross domain)
}()); b[c] += ( window.postMessage && request ? ' ' : ' no-' ) + cs;
</script> }());
</script>
<!--<![endif]-->
<?php <?php
} }

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.7-alpha-38648'; $wp_version = '4.7-alpha-38649';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.