-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from moreonion/script-attributes
feat: Allow passing custom attributes for script tags
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
namespace Drupal\theming; | ||
|
||
use Upal\DrupalUnitTestCase; | ||
|
||
/** | ||
* Test hook and callback implementations for the theming module. | ||
*/ | ||
class ModuleTest extends DrupalUnitTestCase { | ||
|
||
/** | ||
* Test that it’s possible to override the type attribute of a <script> tag. | ||
*/ | ||
public function testPreRenderScriptsOverridesType() { | ||
$example_url = 'https://example.com/test.js'; | ||
$elements['#items'] = [ | ||
$example_url => [ | ||
'type' => 'external', | ||
'defer' => FALSE, | ||
'attributes' => ['type' => 'module'], | ||
'data' => $example_url, | ||
], | ||
]; | ||
$processed_elements = \theming_pre_render_scripts($elements); | ||
$this->assertEqual([ | ||
'type' => 'module', | ||
'src' => $example_url, | ||
], $processed_elements['scripts'][1]['#attributes']); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters