Skip to content

Commit 162c3f5

Browse files
authored
Merge pull request #17 from Machy8/attributes-fix
Remove type attribute from script and style elements
2 parents 51f24d6 + 0683eb0 commit 162c3f5

15 files changed

+50
-50
lines changed

.github/workflows/tests.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
tests:
7+
name: Tests
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
13+
- name: Install packages
14+
run: composer install --no-interaction
15+
16+
- name: CS Check
17+
run: composer cs:check
18+
19+
- name: PHPstan check
20+
run: composer phpstan:check
21+
22+
- name: Unit Tests
23+
run: composer tester:check
24+
25+
# - name: Coveralls
26+
# uses: coverallsapp/github-action@1.1.3
27+
# with:
28+
# github-token: ${{ secrets.COVERALLS_TOKEN }}
29+
# path-to-lcov: 'lcov.info'

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ vendor/
55
/tests/nette-tester/output/
66
composer.lock
77
docker-compose.yml
8-
coverage.xml
8+
lcov.info

.travis.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
"nette/tester": "^2.4",
1313
"tubalmartin/cssmin": "^4.1",
1414
"machy8/google-closure-compiler": "^1.0",
15-
"phpstan/phpstan": "^0.12",
16-
"symplify/easy-coding-standard": "^9.2",
17-
"symplify/config-transformer": "^9.2",
15+
"phpstan/phpstan": "^1.2",
16+
"symplify/easy-coding-standard": "^10.0",
17+
"symplify/config-transformer": "^10.0",
1818
"nette/di": "^3.0"
1919
},
2020
"suggest": {
@@ -34,7 +34,7 @@
3434
"cs:check": "vendor/bin/ecs check src -c tests/coding-standard/ecs.php",
3535
"cs:fix": "vendor/bin/ecs check src -c tests/coding-standard/ecs.php",
3636
"phpstan:check": "phpstan analyse -c tests/phpstan/phpstan.neon -l 5 src tests/nette-tester",
37-
"tester:check": "tester -p phpdbg tests/nette-tester -s --coverage ./coverage.xml --coverage-src ./src"
37+
"tester:check": "tester -p phpdbg tests/nette-tester -s --coverage ./lcov.info --coverage-src ./src"
3838
},
3939
"minimum-stability": "dev",
4040
"prefer-stable" : true

src/WebLoader/FilesCollectionRender.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ class FilesCollectionRender
2424
private const LINK_PRELOAD_AS_CSS = 'style';
2525
private const LINK_PRELOAD_AS_JS = 'script';
2626

27-
private const SCRIPT_TYPE_ATTRIBUTE = 'text/javascript';
28-
private const STYLE_TYPE_ATTRIBUTE = 'text/css';
29-
3027
private const VERSION_MARK = '?v=';
3128

3229
/**
@@ -63,7 +60,6 @@ public function css(?string $collectionName = null, array $attributes = [], bool
6360
$collectionName = $collection->getName();
6461
$this->compiler->compileFilesCollectionByType(Engine::CSS, $collectionName);
6562
$attributes = array_merge($attributes, $collection->getOutputElementAttributes());
66-
$attributes['type'] = self::STYLE_TYPE_ATTRIBUTE;
6763
$element = self::STYLE_ELEMENT;
6864
$basePath = $this->getCollectionBasePath($collectionName, Engine::CSS);
6965
$filePathParameter = null;
@@ -118,7 +114,6 @@ public function js(?string $collectionName = null, array $attributes = [], bool
118114
$collectionName = $collection->getName();
119115
$this->compiler->compileFilesCollectionByType(Engine::JS, $collectionName);
120116
$attributes = array_merge($attributes, $collection->getOutputElementAttributes());
121-
$attributes['type'] = self::SCRIPT_TYPE_ATTRIBUTE;
122117
$basePath = $this->getCollectionBasePath($collectionName, Engine::JS);
123118
$filePathParameter = null;
124119

tests/nette-tester/CompilerTestsCase.phpt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ final class CompilerTestsCase extends AbstractTestCase
3737
});
3838

3939
Assert::equal(
40-
'<link type="text/css" rel="stylesheet" href="/' . self::BASE_PATH . '/' . $collectionName . '.css?v=' . $this->getFilesVersion() . '">',
40+
'<link rel="stylesheet" href="/' . self::BASE_PATH . '/' . $collectionName . '.css?v=' . $this->getFilesVersion() . '">',
4141
$webLoader->getFilesCollectionRender()->css($collectionName)
4242
);
4343

@@ -66,7 +66,7 @@ final class CompilerTestsCase extends AbstractTestCase
6666
$webLoader = $this->getWebLoader();
6767

6868
Assert::equal(
69-
'<script async type="text/javascript" src="/' . self::BASE_PATH . '/' . $collectionName . '.js?v=' . $this->getFilesVersion() . '"></script>',
69+
'<script async src="/' . self::BASE_PATH . '/' . $collectionName . '.js?v=' . $this->getFilesVersion() . '"></script>',
7070
$webLoader->getFilesCollectionRender()->js($collectionName, ['async' => TRUE])
7171
);
7272

@@ -110,12 +110,12 @@ final class CompilerTestsCase extends AbstractTestCase
110110
$render = $webLoader->getFilesCollectionRender();
111111

112112
Assert::equal(
113-
'<link type="text/css" rel="stylesheet" href="/' . self::BASE_PATH . '/' . $collectionNameA . '.css?v=' . $this->getFilesVersion() . '">',
113+
'<link rel="stylesheet" href="/' . self::BASE_PATH . '/' . $collectionNameA . '.css?v=' . $this->getFilesVersion() . '">',
114114
$render->css($collectionNameA)
115115
);
116116

117117
Assert::equal(
118-
'<script defer async type="text/javascript" src="/' . self::BASE_PATH . '/' . $collectionNameB . '.js?v=' . $this->getFilesVersion() . '"></script>',
118+
'<script defer async src="/' . self::BASE_PATH . '/' . $collectionNameB . '.js?v=' . $this->getFilesVersion() . '"></script>',
119119
$render->js($collectionNameB, ['defer' => TRUE])
120120
);
121121

@@ -163,8 +163,8 @@ final class CompilerTestsCase extends AbstractTestCase
163163

164164
$render = $webLoader->getFilesCollectionsContainerRender()->selectContainer('testContainer');
165165

166-
$collectionALink = '<link type="text/css" rel="stylesheet" href="/' . self::BASE_PATH . '/' . $collectionNameA . '.css?v=' . $this->getFilesVersion() . '">';
167-
$collectionBLink = '<link type="text/css" rel="stylesheet" href="/' . self::BASE_PATH . '/' . $collectionNameB . '.css?v=' . $this->getFilesVersion() . '">';
166+
$collectionALink = '<link rel="stylesheet" href="/' . self::BASE_PATH . '/' . $collectionNameA . '.css?v=' . $this->getFilesVersion() . '">';
167+
$collectionBLink = '<link rel="stylesheet" href="/' . self::BASE_PATH . '/' . $collectionNameB . '.css?v=' . $this->getFilesVersion() . '">';
168168
Assert::equal($collectionALink . $collectionBLink, $render->css());
169169

170170
$collectionALink = '<link rel="prefetch" href="/' . self::BASE_PATH . '/' . $collectionNameA . '.css?v=' . $this->getFilesVersion() . '">';
@@ -175,8 +175,8 @@ final class CompilerTestsCase extends AbstractTestCase
175175
$collectionBLink = '<link rel="preload" as="style" href="/' . self::BASE_PATH . '/' . $collectionNameB . '.css?v=' . $this->getFilesVersion() . '">';
176176
Assert::equal($collectionALink . $collectionBLink, $render->cssPreload());
177177

178-
$collectionALink = '<script async defer type="text/javascript" src="/' . self::BASE_PATH . '/' . $collectionNameA . '.js?v=' . $this->getFilesVersion() . '"></script>';
179-
$collectionBLink = '<script async defer type="text/javascript" src="/' . self::BASE_PATH . '/' . $collectionNameB . '.js?v=' . $this->getFilesVersion() . '"></script>';
178+
$collectionALink = '<script async defer src="/' . self::BASE_PATH . '/' . $collectionNameA . '.js?v=' . $this->getFilesVersion() . '"></script>';
179+
$collectionBLink = '<script async defer src="/' . self::BASE_PATH . '/' . $collectionNameB . '.js?v=' . $this->getFilesVersion() . '"></script>';
180180
Assert::equal($collectionALink . $collectionBLink, $render->js(NULL, ['async' => TRUE, 'defer' => TRUE]));
181181

182182
$collectionALink = '<link rel="prefetch" href="/' . self::BASE_PATH . '/' . $collectionNameA . '.js?v=' . $this->getFilesVersion() . '">';

tests/nette-tester/webtemp/actual/test-css-files-collection-style-element.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<style amp-custom type="text/css">
1+
<style amp-custom>
22
a {
33
color: steelblue;
44
font-weight: bold;

tests/nette-tester/webtemp/actual/test-files-collections-from-config-a.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<script type="text/javascript">
1+
<script>
22
;(function ($) {
33
var codeFragment = 'jQuery! muhehe';
44

tests/nette-tester/webtemp/actual/test-files-collections-from-config-b.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<style amp-custom type="text/css">
1+
<style amp-custom>
22
div {
33
display: inline-block;
44
width: 50px;

tests/nette-tester/webtemp/actual/test-js-files-collection-script-element-with-content.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<script type="text/javascript">
1+
<script>
22
;(function ($) {
33
var codeFragment = 'jQuery! muhehe';
44

0 commit comments

Comments
 (0)