Skip to content

Commit

Permalink
Merge pull request #17 from Machy8/attributes-fix
Browse files Browse the repository at this point in the history
Remove type attribute from script and style elements
  • Loading branch information
Machy8 committed Dec 26, 2021
2 parents 51f24d6 + 0683eb0 commit 162c3f5
Show file tree
Hide file tree
Showing 15 changed files with 50 additions and 50 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Tests

on: [push, pull_request]

jobs:
tests:
name: Tests
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Install packages
run: composer install --no-interaction

- name: CS Check
run: composer cs:check

- name: PHPstan check
run: composer phpstan:check

- name: Unit Tests
run: composer tester:check

# - name: Coveralls
# uses: coverallsapp/github-action@1.1.3
# with:
# github-token: ${{ secrets.COVERALLS_TOKEN }}
# path-to-lcov: 'lcov.info'
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ vendor/
/tests/nette-tester/output/
composer.lock
docker-compose.yml
coverage.xml
lcov.info
22 changes: 0 additions & 22 deletions .travis.yml

This file was deleted.

8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"nette/tester": "^2.4",
"tubalmartin/cssmin": "^4.1",
"machy8/google-closure-compiler": "^1.0",
"phpstan/phpstan": "^0.12",
"symplify/easy-coding-standard": "^9.2",
"symplify/config-transformer": "^9.2",
"phpstan/phpstan": "^1.2",
"symplify/easy-coding-standard": "^10.0",
"symplify/config-transformer": "^10.0",
"nette/di": "^3.0"
},
"suggest": {
Expand All @@ -34,7 +34,7 @@
"cs:check": "vendor/bin/ecs check src -c tests/coding-standard/ecs.php",
"cs:fix": "vendor/bin/ecs check src -c tests/coding-standard/ecs.php",
"phpstan:check": "phpstan analyse -c tests/phpstan/phpstan.neon -l 5 src tests/nette-tester",
"tester:check": "tester -p phpdbg tests/nette-tester -s --coverage ./coverage.xml --coverage-src ./src"
"tester:check": "tester -p phpdbg tests/nette-tester -s --coverage ./lcov.info --coverage-src ./src"
},
"minimum-stability": "dev",
"prefer-stable" : true
Expand Down
5 changes: 0 additions & 5 deletions src/WebLoader/FilesCollectionRender.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@ class FilesCollectionRender
private const LINK_PRELOAD_AS_CSS = 'style';
private const LINK_PRELOAD_AS_JS = 'script';

private const SCRIPT_TYPE_ATTRIBUTE = 'text/javascript';
private const STYLE_TYPE_ATTRIBUTE = 'text/css';

private const VERSION_MARK = '?v=';

/**
Expand Down Expand Up @@ -63,7 +60,6 @@ public function css(?string $collectionName = null, array $attributes = [], bool
$collectionName = $collection->getName();
$this->compiler->compileFilesCollectionByType(Engine::CSS, $collectionName);
$attributes = array_merge($attributes, $collection->getOutputElementAttributes());
$attributes['type'] = self::STYLE_TYPE_ATTRIBUTE;
$element = self::STYLE_ELEMENT;
$basePath = $this->getCollectionBasePath($collectionName, Engine::CSS);
$filePathParameter = null;
Expand Down Expand Up @@ -118,7 +114,6 @@ public function js(?string $collectionName = null, array $attributes = [], bool
$collectionName = $collection->getName();
$this->compiler->compileFilesCollectionByType(Engine::JS, $collectionName);
$attributes = array_merge($attributes, $collection->getOutputElementAttributes());
$attributes['type'] = self::SCRIPT_TYPE_ATTRIBUTE;
$basePath = $this->getCollectionBasePath($collectionName, Engine::JS);
$filePathParameter = null;

Expand Down
16 changes: 8 additions & 8 deletions tests/nette-tester/CompilerTestsCase.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ final class CompilerTestsCase extends AbstractTestCase
});

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

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

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

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

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

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

Expand Down Expand Up @@ -163,8 +163,8 @@ final class CompilerTestsCase extends AbstractTestCase

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

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

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

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

$collectionALink = '<link rel="prefetch" href="/' . self::BASE_PATH . '/' . $collectionNameA . '.js?v=' . $this->getFilesVersion() . '">';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<style amp-custom type="text/css">
<style amp-custom>
a {
color: steelblue;
font-weight: bold;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script type="text/javascript">
<script>
;(function ($) {
var codeFragment = 'jQuery! muhehe';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<style amp-custom type="text/css">
<style amp-custom>
div {
display: inline-block;
width: 50px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script type="text/javascript">
<script>
;(function ($) {
var codeFragment = 'jQuery! muhehe';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<style amp-custom type="text/css">
<style amp-custom>
a {
color: steelblue;
font-weight: bold;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script type="text/javascript">
<script>
;(function ($) {
var codeFragment = 'jQuery! muhehe';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<style amp-custom type="text/css">
<style amp-custom>
div {
display: inline-block;
width: 50px;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script type="text/javascript">
<script>
;(function ($) {
var codeFragment = 'jQuery! muhehe';

Expand Down
2 changes: 0 additions & 2 deletions tests/phpstan/phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
parameters:
autoload_files:
- ../nette-tester/AbstractTestCase.php
ignoreErrors:
- '#Property [a-zA-Z0-9\\_]+::\$[a-zA-Z0-9_]+ \([\S]+\) does not accept [\S\|]+\.#'

0 comments on commit 162c3f5

Please sign in to comment.