Browse Source

fcl-css: test inline style

mattias 2 years ago
parent
commit
d4a7431938

+ 1 - 3
packages/fcl-css/src/fpcssparser.pp

@@ -319,8 +319,7 @@ Var
   aEl : TCSSElement;
   Terms : TCSSTokens;
 begin
-  Terms:=[ctkEOF];
-  Include(Terms,aStopOn);
+  Terms:=[ctkEOF,aStopOn];
   aList:=TCSSCompoundElement(CreateElement(TCSSCompoundElement));
   Try
     While not (CurrentToken in Terms) do
@@ -346,7 +345,6 @@ begin
     Result:=ParseRuleList;
 end;
 
-
 function TCSSParser.GetNextToken: TCSSToken;
 begin
   FPrevious:=FCurrent;

+ 3 - 0
packages/fcl-css/src/fpcssresolver.pas

@@ -317,6 +317,9 @@ var
 begin
   if El=nil then exit;
   C:=El.ClassType;
+  {$IFDEF VerboseCSSResolver}
+  //writeln('TCSSResolver.ComputeElement ',GetCSSPath(El));
+  {$ENDIF}
   if C=TCSSCompoundElement then
   begin
     Compound:=TCSSCompoundElement(El);

+ 20 - 0
packages/fcl-css/tests/tccssresolver.pp

@@ -243,11 +243,13 @@ type
     // ToDo: :lang()
 
     // ToDo: inline style
+    procedure Test_InlineStyle;
 
     // ToDo: specifity
 
     // pseudo elements
 
+    // skipping for forward compatibility
     // ToDo: invalid token in selector makes selector invalid
 
   end;
@@ -921,6 +923,24 @@ begin
   AssertEquals('Div2.Top','',Div2.Top);
 end;
 
+procedure TTestCSSResolver.Test_InlineStyle;
+var
+  Div1: TDemoDiv;
+begin
+  Doc.Root:=TDemoNode.Create(nil);
+
+  Div1:=TDemoDiv.Create(Doc);
+  Div1.Parent:=Doc.Root;
+  Div1.Style:='left: 10px;';
+
+  Doc.Style:=LinesToStr([
+  'div { left: 6px; }',
+  '']);
+  Doc.ApplyStyle;
+  AssertEquals('Root.Left','',Doc.Root.Left);
+  AssertEquals('Div1.Left','10px',Div1.Left);
+end;
+
 { TDemoDiv }
 
 class function TDemoDiv.CSSTypeName: TCSSString;