mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 21:01:34 +08:00
url syntax fixed
This commit is contained in:
@ -345,12 +345,13 @@ export var backgroundImageProperty = new styleProperty.Property("backgroundImage
|
|||||||
|
|
||||||
function onBackgroundImagePropertyChanged(data: observable.PropertyChangeData) {
|
function onBackgroundImagePropertyChanged(data: observable.PropertyChangeData) {
|
||||||
var style = <Style>data.object;
|
var style = <Style>data.object;
|
||||||
var newValue = <string>data.newValue;
|
var pattern: RegExp = /url\(('|")(.*?)\1\)/;
|
||||||
|
var url = (<string>data.newValue).match(pattern)[2];
|
||||||
|
|
||||||
if (imageSource.isFileOrResourcePath(newValue)) {
|
if (imageSource.isFileOrResourcePath(url)) {
|
||||||
style._setValue(backgroundImageSourceProperty, imageSource.fromFileOrResource(newValue), observable.ValueSource.Local);
|
style._setValue(backgroundImageSourceProperty, imageSource.fromFileOrResource(url), observable.ValueSource.Local);
|
||||||
} else if (types.isString(newValue)) {
|
} else if (types.isString(url)) {
|
||||||
imageSource.fromUrl(newValue).then(r=> {
|
imageSource.fromUrl(url).then(r=> {
|
||||||
style._setValue(backgroundImageSourceProperty, r, observable.ValueSource.Local);
|
style._setValue(backgroundImageSourceProperty, r, observable.ValueSource.Local);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user