WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/18/2019 02:49:30 PM (8 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/scripts.php

    r45979 r46164  
    4545        wp_enqueue_script( 'empty-deps-version', 'example.com', array(), 1.2 );
    4646        wp_enqueue_script( 'empty-deps-null-version', 'example.com', array(), null );
     47
    4748        $ver       = get_bloginfo( 'version' );
    4849        $expected  = "<script type='text/javascript' src='http://example.com?ver=$ver'></script>\n";
     
    5556        // No scripts left to print
    5657        $this->assertEquals( '', get_echo( 'wp_print_scripts' ) );
     58    }
     59
     60    /**
     61     * @ticket 42804
     62     */
     63    function test_wp_enqueue_script_with_html5_support_does_not_contain_type_attribute() {
     64        add_theme_support( 'html5', array( 'script' ) );
     65
     66        $GLOBALS['wp_scripts']                  = new WP_Scripts();
     67        $GLOBALS['wp_scripts']->default_version = get_bloginfo( 'version' );
     68
     69        wp_enqueue_script( 'empty-deps-no-version', 'example.com' );
     70
     71        $ver      = get_bloginfo( 'version' );
     72        $expected = "<script src='http://example.com?ver=$ver'></script>\n";
     73
     74        $this->assertEquals( $expected, get_echo( 'wp_print_scripts' ) );
    5775    }
    5876
Note: See TracChangeset for help on using the changeset viewer.