From d77ca4e98bea6ca6977f2b4007d1d77d7513453f Mon Sep 17 00:00:00 2001 From: Rintim Date: Thu, 7 Sep 2023 22:13:47 +0800 Subject: [PATCH] add css selector linq. --- game/game.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/game/game.js b/game/game.js index ebd043215..14260a993 100644 --- a/game/game.js +++ b/game/game.js @@ -7176,8 +7176,19 @@ } }, linq:{ - css:{ - merge:function(){return Array.from(arguments).join(",")} + cselector:{ + hasAttr:name=>`[${name}]`, + isAttr:(name,item)=>`[${name}=${item}]`, + inAttr:(name,item)=>`[${name}~=${item}]`, + conAttr:(name,item)=>`[${name}*=${item}]`, + onAttr:(name,item)=>`[${name}|=${item}]`, + bgnAttr:(name,item)=>`[${name}^=${item}]`, + endAttr:(name,item)=>`[${name}^=${item}]`, + merge:function(){return Array.from(arguments).join(" ");}, + concat:function(){return Array.from(arguments).join("");}, + class:function(){return `.${Array.from(arguments).join(".")}`;}, + group:function(){return Array.from(arguments).join(",");}, + media:type=>`@media ${type}` } }, init:{ @@ -32182,7 +32193,11 @@ } return result.join(" "); }, - generate:(name, style)=>[`${name} {`, game.dynamicStyle.translate(style), "}"].join(" ") + generate:(name, style)=>[`${name} {`, game.dynamicStyle.translate(style), "}"].join(" "), + has:name=>game.dynamicStyle._cache.rules.some(item=>item[0]==name), + get:name=>game.dynamicStyle.find(item=>item[0]==name), + find:fn=>game.dynamicStyle._cache.rules.find(fn), + size:()=>game.dynamicStyle._cache.rules.length }, //Add a background music to the config option //在设置选项中添加一首背景音乐