Skip to content

Commit 2946017

Browse files
committed
skip css variable links
1 parent b2e170a commit 2946017

File tree

3 files changed

+38
-9
lines changed

3 files changed

+38
-9
lines changed

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ import "@polymer/paper-button/paper-button.html";
221221
### Assets
222222

223223
```html
224+
works inside html.
224225
<!-- imports/ui/path/to/element.html -->
225226
<img src="sample-image.png"> <!--Works!!-->
226227
<iron-image src="sample-image.png"><iron-image> <!--Works!!-->
@@ -230,9 +231,22 @@ import "@polymer/paper-button/paper-button.html";
230231
<any-element src="{{image}}"><any-element> <!--Does not work!! if you want this to work use image = path/from/root/to/image.png -->
231232

232233
<!-- files in public/ folder -->
233-
<any-element src="/sample-image.png"><any-element> <!--Works!! src = /sample-image.png -->
234-
```
235-
works inside html.
234+
<any-element src="/sample-image.png"><any-element> <!--Works!! file should be in public folder src = /sample-image.png -->
235+
works inside css.
236+
```
237+
238+
```css
239+
240+
/*imports/ui/path/to/element.html inside style tag or imports/ui/path/to/element.css */
241+
background: url(path/to/image.png); /* Works!!. */
242+
property: url(relative/path/to/image.png); /* Works!!. */
243+
property: url(var(--url-var)); /* Does not work unless --url-var = absolute path imports/ui/path/to/image.png */
244+
/* if you want to use variables use
245+
--url-var = url(path/to/url);
246+
property: var(--url-var);
247+
*/
248+
property: url(/path/to/image.png); /* Works!!. if file is in public folder */
249+
```
236250

237251
File types we supports https://github.com/meteorwebcomponents/synthesis/blob/master/packages/synthesis-file/plugin/synthesis-file.js#L19.
238252

packages/synthesis-compiler/synthesis-compiler.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,8 @@ class DissectHtml {
265265
return null;
266266
}
267267
_changeRelUrl(inpUrl) {
268-
// avoids [[prop]] and {{prop}}
269-
if (inpUrl && !inpUrl.match(/({{|\[\[)\s*[\w\.]+\s*(}}|\]\])/g)) {
268+
// avoids var(--url-variable);
269+
if (inpUrl && !inpUrl.match(/var\(.*?\)/g)) {
270270
// avoids absolute & remote urls
271271
const url = this.importableUrl(inpUrl);
272272
if (url) {
@@ -282,7 +282,7 @@ class DissectHtml {
282282

283283
const processed = text.replace(/url\(.*?\)/ig, function(a) {
284284
// to get -> filepath from url(filepath), url('filepath') and url("filepath")
285-
const processedUrl = a.replace(/\(['|"]?([^)]+?)['|"]?\)/, function(_url, inpUrl) {
285+
const processedUrl = a.replace(/\(['|"]?([^)]+?)['|"]?\)/i, function(_url, inpUrl) {
286286
return `(${self._changeRelUrl(inpUrl)})`;
287287
});
288288
return processedUrl;

packages/synthesis/README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ import "@polymer/paper-button/paper-button.html";
221221
### Assets
222222

223223
```html
224+
works inside html.
224225
<!-- imports/ui/path/to/element.html -->
225226
<img src="sample-image.png"> <!--Works!!-->
226227
<iron-image src="sample-image.png"><iron-image> <!--Works!!-->
@@ -230,9 +231,22 @@ import "@polymer/paper-button/paper-button.html";
230231
<any-element src="{{image}}"><any-element> <!--Does not work!! if you want this to work use image = path/from/root/to/image.png -->
231232

232233
<!-- files in public/ folder -->
233-
<any-element src="/sample-image.png"><any-element> <!--Works!! src = /sample-image.png -->
234-
```
235-
works inside html.
234+
<any-element src="/sample-image.png"><any-element> <!--Works!! file should be in public folder src = /sample-image.png -->
235+
works inside css.
236+
```
237+
238+
```css
239+
240+
/*imports/ui/path/to/element.html inside style tag or imports/ui/path/to/element.css */
241+
background: url(path/to/image.png); /* Works!!. */
242+
property: url(relative/path/to/image.png); /* Works!!. */
243+
property: url(var(--url-var)); /* Does not work unless --url-var = absolute path imports/ui/path/to/image.png */
244+
/* if you want to use variables use
245+
--url-var = url(path/to/url);
246+
property: var(--url-var);
247+
*/
248+
property: url(/path/to/image.png); /* Works!!. if file is in public folder */
249+
```
236250

237251
File types we supports https://github.com/meteorwebcomponents/synthesis/blob/master/packages/synthesis-file/plugin/synthesis-file.js#L19.
238252

@@ -308,3 +322,4 @@ But there are some compatibility issues https://forums.meteor.com/t/polymer-mete
308322
Q: I love blaze's template level subscriptions and spacebars. I dont want to lose these features when I port my app to polymer. Any help?
309323

310324
Ans : In my experience I find nothing that polymer cannot do which blaze can. Polymer is very easy to learn and while porting your app you'll find yourself copy pasting most of your code. For every blaze function they have solutions in polymer. We have got you covered when it comes to meteor data and subscriptions (including template level subs) Refer [mixin](https://github.com/meteorwebcomponents/mixin) .
325+

0 commit comments

Comments
 (0)