RAIN must handle correctly two fragments included in the same view via the webcomponent protocol that define the same CSS selectors and solve name clash automatically. Also it should permit to the author of the page to associate the specific CSS class with the component in the page.
Below you can see two examples of including css files (with module version or latest version) using webcomponent protocol:
1 2 3 4 5 6 | <head>
<title>Page Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="webcomponent://core-components;1.0/htdocs/css/application.css" />
<link rel="stylesheet" type="text/css" href="webcomponent://cp-components;1.0/htdocs/css/application.css" />
</head>
|
1 2 3 4 5 6 | <head>
<title>Page Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" href="webcomponent://core-components/htdocs/css/application.css"/>
<link rel="stylesheet" type="text/css" href="webcomponent://cp-components/htdocs/css/application.css"/>
</head>
|
The Rain platform should:
All identified css classes from the aggregator page will be consolidated within one single file (or accessible url). Each class will be prefixed with a key composed from module identifier and module version. What happens when we have nested fragments? For instance we have the following scenario:
The block element generated by Rain (assumption 1) will automatically contain in the class attribute the key added in css to avoid name clashes. This solves the issue transparently for the developer and is not constraint to a specific number of nested levels.
What happens when we have nested fragments? For instance we have the following scenario:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 <!--main view--> <head> <link rel="stylesheet" href="webcomponent://example;1.0/htdocs/css/test.css" /> </head> <body>Features-proposal-css-transformation <fragment1 /> <fragment1 /> <fragment1 /> </body> .... <!--fragment1 view--> <head> <link rel="stylesheet" href="webcomponent://example;1.1/htdocs/css/test2.css" /> </head> <body> <p>Ta na na na na. Css possible class clash?</p> </body>A: First let’s mock the content of each css file.
1 2 3 4 5 <!-- test.css --> .myTestClass {background-color: red;} <!-- test2.css --> .myTestClass {background-color: red;}Rain consolidates both css files into:
1 2 3 4 5 <!-- ..... consolidated-url.css --> <!-- test.css --> .example-1.0 .myTestClass {background-color: red;} <!-- test2.css --> .example-1.1 .myTestClass {background-color: red;}The resulting html seen in client browser is:
1 2 3 4 5 6 7 8 9 <!--main view--> <head> <link rel="stylesheet" href="..... consolidated-url.css" /> </head> <body> <div class="example-1.0" id="[unique identifier at dom level generated by RAIN]"> <p>Ta na na na na. Css possible class clash?</p> </div> </body>