MDL-78334 core: Add a mechanism to deprecate SCSS code

This commit is contained in:
Mikel Martín
2023-11-09 13:42:18 +01:00
parent e4d1369475
commit eab94ea4c8
6 changed files with 77 additions and 0 deletions
+28
View File
@@ -1007,6 +1007,31 @@ EOF;
}
}
/**
* Internal step definition to find deprecated styles.
*
* Part of behat_hooks class as is part of the testing framework, is auto-executed
* after each step so no features will splicitly use it.
*
* @throws Exception Unknown type, depending on what we caught in the hook or basic \Exception.
* @see Moodle\BehatExtension\Tester\MoodleStepTester
*/
public function look_for_deprecated_styles() {
if (!$this->running_javascript()) {
return;
}
// Look for any DOM element with deprecated message in before pseudo-element.
$js = <<<EOF
[...document.querySelectorAll('*')].some(
el => window.getComputedStyle(el, ':before').content === '"Deprecated style in use"'
);
EOF;
if ($this->evaluate_script($js)) {
throw new \Exception(html_entity_decode("Deprecated style in use", ENT_COMPAT));
}
}
/**
* Converts HTML tags to line breaks to display the info in CLI
*
@@ -1045,6 +1070,9 @@ EOF;
// Look for exceptions.
$this->look_for_exceptions();
// Look for deprecated styles.
$this->look_for_deprecated_styles();
}
/**