Skip to content

Element 'css', attribute 'as': The attribute 'as' is not allowed. (CSS preloading) #18347

Closed
@benoitrenaud

Description

@benoitrenaud

Hi,
We want to use a technique for loading asynchronous stylesheets.
Ex. https://brianflove.com/2016/07/21/preloading-with-critical-path-css/

The issue is that link attribute "as" isn't valid according to vendor/magento/framework/View/Layout/etc/head.xsd validation file but is a officially supported HTML link attribute as described here:
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#Attributes

Preconditions

  1. Magento 2.2.6
  2. PHP 7.1

Steps to reproduce

  1. I add the attribute AS on my css inclusion:
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head> 
        <css src="/style.css" src_type="url" rel="preload" as="style" /> 
    </head>
</page>
  1. Clear cache
  2. Reload the front

Expected result

  1. Permit the AS attribute (https://developer.mozilla.org/en-US/docs/Web/HTML/Element/link#Attributes) in this file vendor/magento/framework/View/Layout/etc/head.xsd
  2. Add this <xs:attribute name="as" type="xs:string"/> under <xs:complexType name="linkType">

Actual result

An exception is thrown by Magento Framework 1 exception(s): Exception #0 (Magento\Framework\Config\Dom\ValidationException): Element 'css', attribute 'as': The attribute 'as' is not allowed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Component: Framework/ViewComponent: ThemeFixed in 2.2.xThe issue has been fixed in 2.2 release lineFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentProgress: PR CreatedIndicates that Pull Request has been created to fix issueReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releasegood first issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions