Improved: Minz Framework. Byebye Internet Explorer and its Conditional comments (#4651)

* Update View.php

* Update lib/Minz/View.php

* Update lib/Minz/View.php

* Update lib/Minz/View.php

Co-authored-by: Frans de Jonge <fransdejonge@gmail.com>

* Update lib/Minz/View.php

* Update lib/Minz/View.php

* Update lib/Minz/View.php

* Update lib/Minz/View.php

* Update lib/Minz/View.php

* Update lib/Minz/View.php

* Update lib/Minz/View.php

Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Co-authored-by: Frans de Jonge <fransdejonge@gmail.com>
This commit is contained in:
maTh 2022-11-22 08:18:52 +01:00 committed by GitHub
parent 88ef6174c0
commit 18a4ade32f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 33 additions and 27 deletions

View File

@ -202,36 +202,38 @@ class Minz_View {
$styles = '';
foreach(self::$styles as $style) {
$cond = $style['cond'];
if ($cond) {
$styles .= '<!--[if ' . $cond . ']>';
}
$styles .= '<link rel="stylesheet" ' .
($style['media'] === 'all' ? '' : 'media="' . $style['media'] . '" ') .
'href="' . $style['url'] . '" />';
if ($cond) {
$styles .= '<![endif]-->';
}
$styles .= "\n";
}
return $styles;
}
public static function prependStyle ($url, $media = 'all', $cond = false) {
/**
* Prepends a <link> element referencing stylesheet.
*
* @param string $url
* @param string $media
* @param bool $cond Conditional comment for IE, now deprecated and ignored
*/
public static function prependStyle($url, $media = 'all', $cond = false) {
array_unshift (self::$styles, array (
'url' => $url,
'media' => $media,
'cond' => $cond
));
}
public static function appendStyle ($url, $media = 'all', $cond = false) {
/**
* Append a `<link>` element referencing stylesheet.
* @param string $url
* @param string $media
* @param bool $cond Conditional comment for IE, now deprecated and ignored
*/
public static function appendStyle($url, $media = 'all', $cond = false) {
self::$styles[] = array (
'url' => $url,
'media' => $media,
'cond' => $cond
);
}
@ -242,11 +244,6 @@ class Minz_View {
$scripts = '';
foreach (self::$scripts as $script) {
$cond = $script['cond'];
if ($cond) {
$scripts .= '<!--[if ' . $cond . ']>';
}
$scripts .= '<script src="' . $script['url'] . '"';
if (!empty($script['id'])) {
$scripts .= ' id="' . $script['id'] . '"';
@ -258,29 +255,38 @@ class Minz_View {
$scripts .= ' async="async"';
}
$scripts .= '></script>';
if ($cond) {
$scripts .= '<![endif]-->';
}
$scripts .= "\n";
}
return $scripts;
}
public static function prependScript ($url, $cond = false, $defer = true, $async = true, $id = '') {
/**
* Prepend a `<script>` element.
* @param string $url
* @param bool $cond Conditional comment for IE, now deprecated and ignored
* @param bool $defer Use `defer` flag
* @param bool $async Use `async` flag
* @param string $id Add a script `id` attribute
*/
public static function prependScript($url, $cond = false, $defer = true, $async = true, $id = '') {
array_unshift(self::$scripts, array (
'url' => $url,
'cond' => $cond,
'defer' => $defer,
'async' => $async,
'id' => $id,
));
}
public static function appendScript ($url, $cond = false, $defer = true, $async = true, $id = '') {
/**
* Append a `<script>` element.
* @param string $url
* @param bool $cond Conditional comment for IE, now deprecated and ignored
* @param bool $defer Use `defer` flag
* @param bool $async Use `async` flag
* @param string $id Add a script `id` attribute
*/
public static function appendScript($url, $cond = false, $defer = true, $async = true, $id = '') {
self::$scripts[] = array (
'url' => $url,
'cond' => $cond,
'defer' => $defer,
'async' => $async,
'id' => $id,