Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:ampproject/amp-wp into enhanceme…
Browse files Browse the repository at this point in the history
…nt/4326-tiktok-embed

* 'develop' of github.com:ampproject/amp-wp:
  Fix ZIP build after namespace rename
  Add missing namespace to common lib tests
  Fix phpcs issues in common and optimizer libs; include tests dir in cs/cbf scripts
  Fix and harden normalizeDomStructure when document lacks <html>
  Move any nodes appearing after </body> to be appended to the body
  Skip moving comments outside of html tags
  Merge changes from #4193
  Merge changes into moved Dom\Document class
  Change root namespace for all three packages
  Deal with whitespace around comments
  Preserve comment positions (without breaking structure)
  Update src/Dom/Document.php
  Support content after html end tag
  • Loading branch information
westonruter committed Mar 7, 2020
2 parents 133d204 + a1b2c36 commit 6d43994
Show file tree
Hide file tree
Showing 123 changed files with 677 additions and 540 deletions.
8 changes: 4 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ module.exports = function( grunt ) {
'vendor/*/*/*.yml',
'vendor/*/*/.*.yml',
'vendor/*/*/tests',
'vendor/amp/optimizer/bin',
'vendor/ampproject/optimizer/bin',
'vendor/bin',
'vendor/amp/common/vendor',
'vendor/amp/optimizer/vendor',
'vendor/ampproject/common/vendor',
'vendor/ampproject/optimizer/vendor',
];

grunt.initConfig( {
Expand Down Expand Up @@ -78,7 +78,7 @@ module.exports = function( grunt ) {
'if [ ! -e build ]; then echo "Run grunt build first."; exit 1; fi',
'cd build',
'composer install --no-dev -o',
'for symlinksource in $(find vendor/amp -type l); do symlinktarget=$(readlink "$symlinksource") && rm "$symlinksource" && cp -r "vendor/amp/$symlinktarget" "$symlinksource"; done',
'for symlinksource in $(find vendor/ampproject -type l); do symlinktarget=$(readlink "$symlinksource") && rm "$symlinksource" && cp -r "vendor/ampproject/$symlinktarget" "$symlinksource"; done',
'composer remove cweagans/composer-patches --update-no-dev -o',
'rm -r ' + productionVendorExcludedFilePatterns.join( ' ' )
].join( ' && ' ),
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"ext-iconv": "*",
"ext-libxml": "*",
"ext-spl": "*",
"amp/common": "^1",
"amp/optimizer": "^1",
"ampproject/common": "^1",
"ampproject/optimizer": "^1",
"cweagans/composer-patches": "1.6.7",
"fasterimage/fasterimage": "1.5.0",
"sabberworm/php-css-parser": "dev-master#134f4e6"
Expand Down Expand Up @@ -51,12 +51,12 @@
},
"autoload": {
"psr-4": {
"Amp\\AmpWP\\": "src/"
"AmpProject\\AmpWP\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Amp\\AmpWP\\Tests\\": "tests/php/src/"
"AmpProject\\AmpWP\\Tests\\": "tests/php/src/"
}
},
"repositories": [
Expand Down
24 changes: 12 additions & 12 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion includes/admin/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @package AMP
*/

use Amp\AmpWP\Admin\SiteHealth;
use AmpProject\AmpWP\Admin\SiteHealth;

/**
* Obsolete constant for flagging when Customizer is opened for AMP.
Expand Down
39 changes: 13 additions & 26 deletions includes/class-amp-theme-support.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
* @package AMP
*/

use Amp\Amp;
use Amp\AmpWP\CachedRemoteGetRequest;
use Amp\AmpWP\ConfigurationArgument;
use Amp\AmpWP\Transformer;
use Amp\Attribute;
use Amp\Dom\Document;
use Amp\Extension;
use Amp\Optimizer;
use Amp\RemoteRequest\CurlRemoteGetRequest;
use Amp\RemoteRequest\FallbackRemoteGetRequest;
use Amp\RemoteRequest\FilesystemRemoteGetRequest;
use Amp\Tag;
use AmpProject\Amp;
use AmpProject\AmpWP\CachedRemoteGetRequest;
use AmpProject\AmpWP\ConfigurationArgument;
use AmpProject\AmpWP\Transformer;
use AmpProject\Attribute;
use AmpProject\Dom\Document;
use AmpProject\Extension;
use AmpProject\Optimizer;
use AmpProject\RemoteRequest\CurlRemoteGetRequest;
use AmpProject\RemoteRequest\FallbackRemoteGetRequest;
use AmpProject\RemoteRequest\FilesystemRemoteGetRequest;
use AmpProject\Tag;

/**
* Class AMP_Theme_Support
Expand Down Expand Up @@ -2183,19 +2183,6 @@ public static function prepare_response( $response, $args = [] ) {

$dom = Document::fromHtml( $response );

// Move anything after </html>, such as Query Monitor output added at shutdown, to be moved before </body>.
while ( $dom->documentElement->nextSibling ) {
// Trailing elements after </html> will get wrapped in additional <html> elements.
if ( 'html' === $dom->documentElement->nextSibling->nodeName ) {
while ( $dom->documentElement->nextSibling->firstChild ) {
$dom->body->appendChild( $dom->documentElement->nextSibling->firstChild );
}
$dom->removeChild( $dom->documentElement->nextSibling );
} else {
$dom->body->appendChild( $dom->documentElement->nextSibling );
}
}

AMP_HTTP::send_server_timing( 'amp_dom_parse', -$dom_parse_start, 'AMP DOM Parse' );

// Make sure scripts from the body get moved to the head.
Expand Down Expand Up @@ -2362,7 +2349,7 @@ private static function get_optimizer( $args ) {
}

/**
* Get the Amp\Optimizer configuration object to use.
* Get the AmpProject\Optimizer configuration object to use.
*
* @param array $args Associative array of arguments to pass into the transformation engine.
* @return Optimizer\Configuration Optimizer configuration to use.
Expand Down
2 changes: 1 addition & 1 deletion includes/deprecated.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ function amp_post_template_add_scripts( $amp_template ) {
* Print boilerplate CSS.
*
* @codeCoverageIgnore
* @deprecated Boilerplate is now automatically added via the amp/optimizer library.
* @deprecated Boilerplate is now automatically added via the ampproject/optimizer library.
* @since 0.3
* @see amp_get_boilerplate_code()
*/
Expand Down
2 changes: 1 addition & 1 deletion includes/embeds/class-amp-facebook-embed.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @package AMP
*/

use Amp\Dom\Document;
use AmpProject\Dom\Document;

/**
* Class AMP_Facebook_Embed_Handler
Expand Down
6 changes: 3 additions & 3 deletions includes/embeds/class-amp-gallery-embed.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* @package AMP
*/

use Amp\Dom\Document;
use Amp\AmpWP\Dom\ElementList;
use Amp\AmpWP\Component\Carousel;
use AmpProject\Dom\Document;
use AmpProject\AmpWP\Dom\ElementList;
use AmpProject\AmpWP\Component\Carousel;

/**
* Class AMP_Gallery_Embed_Handler
Expand Down
2 changes: 1 addition & 1 deletion includes/embeds/class-amp-instagram-embed.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @package AMP
*/

use Amp\Dom\Document;
use AmpProject\Dom\Document;

/**
* Class AMP_Instagram_Embed_Handler
Expand Down
2 changes: 1 addition & 1 deletion includes/embeds/class-amp-twitter-embed-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @package AMP
*/

use Amp\Dom\Document;
use AmpProject\Dom\Document;

/**
* Class AMP_Twitter_Embed_Handler
Expand Down
4 changes: 2 additions & 2 deletions includes/sanitizers/class-amp-base-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @package AMP
*/

use Amp\Dom\Document;
use AmpProject\Dom\Document;

/**
* Class AMP_Base_Sanitizer
Expand Down Expand Up @@ -33,7 +33,7 @@ abstract class AMP_Base_Sanitizer {
/**
* DOM.
*
* @var Document An Amp\Document representation of an HTML document.
* @var Document An AmpProject\Document representation of an HTML document.
*
* @since 0.2
*/
Expand Down
2 changes: 1 addition & 1 deletion includes/sanitizers/class-amp-comments-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @package AMP
*/

use Amp\Dom\Document;
use AmpProject\Dom\Document;

/**
* Class AMP_Comments_Sanitizer
Expand Down
2 changes: 1 addition & 1 deletion includes/sanitizers/class-amp-core-theme-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* @since 1.0
*/

use Amp\Dom\Document;
use AmpProject\Dom\Document;

/**
* Class AMP_Core_Theme_Sanitizer
Expand Down
2 changes: 1 addition & 1 deletion includes/sanitizers/class-amp-embed-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @package AMP
*/

use Amp\Dom\Document;
use AmpProject\Dom\Document;

/**
* Class AMP_Embed_Sanitizer
Expand Down
4 changes: 2 additions & 2 deletions includes/sanitizers/class-amp-gallery-block-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* @package AMP
*/

use Amp\AmpWP\Dom\ElementList;
use Amp\AmpWP\Component\Carousel;
use AmpProject\AmpWP\Dom\ElementList;
use AmpProject\AmpWP\Component\Carousel;

/**
* Class AMP_Gallery_Block_Sanitizer
Expand Down
2 changes: 1 addition & 1 deletion includes/sanitizers/class-amp-link-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @package AMP
*/

use Amp\Dom\Document;
use AmpProject\Dom\Document;

/**
* Class AMP_Link_Sanitizer.
Expand Down
6 changes: 3 additions & 3 deletions includes/sanitizers/class-amp-meta-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
* @package AMP
*/

use Amp\Attribute;
use Amp\Dom\Document;
use Amp\Tag;
use AmpProject\Attribute;
use AmpProject\Dom\Document;
use AmpProject\Tag;

/**
* Class AMP_Meta_Sanitizer.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @package AMP
*/

use Amp\Dom\Document;
use AmpProject\Dom\Document;

/**
* Class AMP_Nav_Menu_Dropdown_Sanitizer
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @package AMP
*/

use Amp\Dom\Document;
use AmpProject\Dom\Document;

/**
* Class AMP_Nav_Menu_Toggle_Sanitizer
Expand Down
2 changes: 1 addition & 1 deletion includes/sanitizers/class-amp-o2-player-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @package AMP
*/

use Amp\Dom\Document;
use AmpProject\Dom\Document;

/**
* Class AMP_O2_Player_Sanitizer
Expand Down
2 changes: 1 addition & 1 deletion includes/sanitizers/class-amp-style-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @package AMP
*/

use Amp\Dom\Document;
use AmpProject\Dom\Document;
use Sabberworm\CSS\RuleSet\DeclarationBlock;
use Sabberworm\CSS\CSSList\CSSList;
use Sabberworm\CSS\Property\Selector;
Expand Down
4 changes: 2 additions & 2 deletions includes/sanitizers/class-amp-tag-and-attribute-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* @package AMP
*/

use Amp\CssLength;
use Amp\Dom\Document;
use AmpProject\CssLength;
use AmpProject\Dom\Document;

/**
* Strips the tags and attributes from the content that are not allowed by the AMP spec.
Expand Down
2 changes: 1 addition & 1 deletion includes/sanitizers/trait-amp-noscript-fallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @package AMP
*/

use Amp\Dom\Document;
use AmpProject\Dom\Document;

/**
* Trait AMP_Noscript_Fallback
Expand Down
2 changes: 1 addition & 1 deletion includes/templates/class-amp-content-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @package AMP
*/

use Amp\Dom\Document;
use AmpProject\Dom\Document;

/**
* Class AMP_Content_Sanitizer
Expand Down
Loading

0 comments on commit 6d43994

Please sign in to comment.