WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/18/2019 02:49:30 PM (12 months ago)
Author:
SergeyBiryukov
Message:

Script Loader: Introduce HTML5 support for scripts and styles.

When a theme declares HTML5 support for script and styles via add_theme_support( 'html5', array( 'script', 'style' ) ), the type="text/javascript" and type="text/css" attributes are omitted.

These attributes are unnecessary in HTML5 and cause warnings in the W3C Markup Validation Service.

Props sasiddiqui, swissspidy, knutsp, SergeyBiryukov.
See #42804.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/dependencies/styles.php

    r44157 r46164  
    5757        wp_enqueue_style( 'no-deps-null-version', 'example.com', array(), null );
    5858        wp_enqueue_style( 'no-deps-null-version-print-media', 'example.com', array(), null, 'print' );
     59
    5960        $ver       = get_bloginfo( 'version' );
    6061        $expected  = "<link rel='stylesheet' id='no-deps-no-version-css'  href='http://example.com?ver=$ver' type='text/css' media='all' />\n";
     
    6768        // No styles left to print
    6869        $this->assertEquals( '', get_echo( 'wp_print_styles' ) );
     70    }
     71
     72    /**
     73     * @ticket 42804
     74     */
     75    function test_wp_enqueue_style_with_html5_support_does_not_contain_type_attribute() {
     76        add_theme_support( 'html5', array( 'style' ) );
     77
     78        $GLOBALS['wp_styles']                  = new WP_Styles();
     79        $GLOBALS['wp_styles']->default_version = get_bloginfo( 'version' );
     80
     81        wp_enqueue_style( 'no-deps-no-version', 'example.com' );
     82
     83        $ver      = get_bloginfo( 'version' );
     84        $expected = "<link rel='stylesheet' id='no-deps-no-version-css'  href='http://example.com?ver=$ver' media='all' />\n";
     85
     86        $this->assertEquals( $expected, get_echo( 'wp_print_styles' ) );
    6987    }
    7088
Note: See TracChangeset for help on using the changeset viewer.