tags with the original nodes on error. * * @since 1.1 * @internal */ trait AMP_Noscript_Fallback { /** * Attributes allowed on noscript fallback elements. * * This is used to prevent duplicated validation errors. * * @since 1.1 * * @var array */ private $noscript_fallback_allowed_attributes = []; /** * Initializes the internal allowed attributes array. * * @since 1.1 * * @param string $tag Tag name to get allowed attributes for. */ protected function initialize_noscript_allowed_attributes( $tag ) { $this->noscript_fallback_allowed_attributes = array_fill_keys( array_keys( AMP_Allowed_Tags_Generated::get_allowed_attributes() ), true ); foreach ( AMP_Allowed_Tags_Generated::get_allowed_tag( $tag ) as $tag_spec ) { // Normally 1 iteration. foreach ( $tag_spec['attr_spec_list'] as $attr_name => $attr_spec ) { $this->noscript_fallback_allowed_attributes[ $attr_name ] = true; if ( isset( $attr_spec['alternative_names'] ) ) { $this->noscript_fallback_allowed_attributes = array_merge( $this->noscript_fallback_allowed_attributes, array_fill_keys( $attr_spec['alternative_names'], true ) ); } } } // Remove attributes which are likely to cause styling conflicts, as the noscript fallback should get treated like it has fill layout. unset( $this->noscript_fallback_allowed_attributes[ Attribute::ID ], $this->noscript_fallback_allowed_attributes[ Attribute::CLASS_ ], $this->noscript_fallback_allowed_attributes[ Attribute::STYLE ] ); } /** * Checks whether the given node is within an AMP-specific