Skip to content
Permalink
Browse files

Use valid type for scripts

  • Loading branch information...
apeschar committed Jun 30, 2019
1 parent dfa38ac commit 65175dab197ef72f255afd32db1011dfe7d2891f
@@ -1,6 +1,11 @@
# Changelog


## 1.20 - 2019-06-30

* Use valid value for script `type` to quiet W3C validator.


## 1.19 - 2019-06-13

* Add *.typekit.net, stackpath.bootstrapcdn.com to CSS whitelist.
@@ -32,7 +32,7 @@ private function rewrite(Tag $script) {
if ($script->hasAttribute('type')) {
$script->setAttribute('data-phast-original-type', $script->getAttribute('type'));
}
$script->setAttribute('type', 'phast-script');
$script->setAttribute('type', 'text/phast');
if ($script->hasAttribute('data-phast-params')) {
$script->removeAttribute('src');
}
@@ -3,7 +3,7 @@ var Promise = phast.ES6Promise;
phast.ScriptsLoader = {};

phast.ScriptsLoader.getScriptsInExecutionOrder = function (document, factory) {
var elements = document.querySelectorAll('script[type="phast-script"]');
var elements = document.querySelectorAll('script[type="text/phast"]');
var nonDeferred = [], deferred = [];
for (var i = 0; i < elements.length; i++) {
if (getSrc(elements[i]) !== undefined && elements[i].hasAttribute('defer')) {
@@ -37,7 +37,7 @@ QUnit.module('ScriptsLoader', function () {
assert.equal(s.getAttribute('id'), 'the-id', 'id is intact');

s = testDoc.createElement('script');
s.setAttribute('type', 'phast-script');
s.setAttribute('type', 'text/phast');
utils.restoreOriginals(s);
assert.notOk(s.hasAttribute('type'), 'type attribute has been removed when no data-phast-original-type');
});
@@ -768,10 +768,10 @@ QUnit.module('ScriptsLoader', function () {
makeElement({'non-phast': ''});
makeElement({});
makeElement({}, 'p');
var inlineDeferred = makeElement({'type': 'phast-script', 'defer': ''});
var deferred = makeElement({'type': 'phast-script', 'defer': '', 'src': 'some-src'});
var inline = makeElement({'type': 'phast-script'});
var external = makeElement({'type': 'phast-script', 'async': ''});
var inlineDeferred = makeElement({'type': 'text/phast', 'defer': ''});
var deferred = makeElement({'type': 'text/phast', 'defer': '', 'src': 'some-src'});
var inline = makeElement({'type': 'text/phast'});
var external = makeElement({'type': 'text/phast', 'async': ''});

var factory = {
makeScriptFromElement: function (element) {
@@ -34,12 +34,12 @@ public function testRewriting() {
$inline = $this->getMatchingElement($inline);
$nonJS = $this->getMatchingElement($nonJS);
$this->assertEquals('phast-script', $notInline->getAttribute('type'));
$this->assertEquals('text/phast', $notInline->getAttribute('type'));
$this->assertEquals('the-src', $notInline->getAttribute('src'));
$this->assertTrue($notInline->hasAttribute('defer'));
$this->assertTrue($notInline->hasAttribute('async'));
$this->assertEquals('phast-script', $inline->getAttribute('type'));
$this->assertEquals('text/phast', $inline->getAttribute('type'));
$this->assertEquals('application/javascript', $inline->getAttribute('data-phast-original-type'));
$this->assertFalse($inline->hasAttribute('async'));
$this->assertEquals('the-inline-content', $inline->textContent);

0 comments on commit 65175da

Please sign in to comment.
You can’t perform that action at this time.