Skip to content

Commit

Permalink
Adjust alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
schlessera committed Dec 9, 2019
1 parent 58ff494 commit bbf08a3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Dom/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ private function normalize_document_structure( $content ) {
if ( ! preg_match( self::HTML_STRUCTURE_BODY_END_TAG, $content, $matches ) ) {
// Only <body> missing.
// @todo This is an expensive regex operation, look into further optimization.
$content = preg_replace( self::HTML_STRUCTURE_HEAD_TAG, '$0<body>', $content, 1 );
$content = preg_replace( self::HTML_STRUCTURE_HEAD_TAG, '$0<body>', $content, 1 );
$content .= '</body>';
}
}
Expand Down
10 changes: 5 additions & 5 deletions tests/php/test-class-amp-dom-document.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,24 +172,24 @@ public function assertEqualMarkup( $expected, $actual ) {
* @covers \Amp\AmpWP\Dom\Document::convert_amp_bind_attributes()
*/
public function test_amp_bind_conversion() {
$original = '<amp-img width=300 height="200" data-foo="bar" selected src="/img/dog.jpg" [src]="myAnimals[currentAnimal].imageUrl"></amp-img>';
$dom = new Document();
$original = '<amp-img width=300 height="200" data-foo="bar" selected src="/img/dog.jpg" [src]="myAnimals[currentAnimal].imageUrl"></amp-img>';
$dom = new Document();
$dom->loadHTML( $original );
$converted = $dom->saveHTML();
$this->assertNotEquals( $original, $converted );
$this->assertContains( Document::AMP_BIND_DATA_ATTR_PREFIX . 'src="myAnimals[currentAnimal].imageUrl"', $converted );
$this->assertContains( 'width="300" height="200" data-foo="bar" selected', $converted );

// Check tag with self-closing attribute.
$original = '<input type="text" role="textbox" class="calc-input" id="liens" name="liens" [value]="(result1 != null) ? result1.liens : \'verifying…\'" />';
$dom = new Document();
$original = '<input type="text" role="textbox" class="calc-input" id="liens" name="liens" [value]="(result1 != null) ? result1.liens : \'verifying…\'" />';
$dom = new Document();
$dom->loadHTML( $original );
$converted = $dom->saveHTML();
$this->assertNotEquals( $original, $converted );

// Preserve trailing slash that is actually the attribute value.
$original = '<a href=/>Home</a>';
$dom = new Document();
$dom = new Document();
$dom->loadHTML( $original );
$converted = $dom->saveHTML( $dom->body->firstChild );
$this->assertEquals( '<a href="/">Home</a>', $converted );
Expand Down

0 comments on commit bbf08a3

Please sign in to comment.