Skip to content

Commit c9fd367

Browse files
committed
fix: some spans fixes
1 parent e4c9eda commit c9fd367

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

Diff for: src/label-common.ts

+11-15
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,29 @@
11
import { isIOS } from '@nativescript/core/platform';
22
import { CssProperty, InheritedCssProperty, makeParser, makeValidator, Property } from '@nativescript/core/ui/core/properties';
3-
import { booleanConverter, Color, CSSType, dip } from '@nativescript/core/ui/core/view';
3+
import { booleanConverter, Color, CSSType, dip, Observable, ViewBase } from '@nativescript/core/ui/core/view';
44
import { Label as TNLabel } from '@nativescript/core/ui/label';
55
import { Style } from '@nativescript/core/ui/styling/style';
66
import { layout } from '@nativescript/core/utils/utils';
77
import { Label as LabelViewDefinition, TextShadow } from './label';
88
import { FormattedString } from '@nativescript/core/ui/text-base/formatted-string';
99
import { Span } from '@nativescript/core/ui/text-base/span';
1010

11-
1211
declare module '@nativescript/core/ui/text-base/formatted-string' {
1312
interface FormattedString {
14-
addPropertyChangeHandler(): void;
15-
removePropertyChangeHandler(): void;
13+
addPropertyChangeHandler(span: Span): void;
14+
removePropertyChangeHandler(span: Span): void;
1615
}
1716
}
18-
declare module '@nativescript/core/ui/text-base/span' {
19-
interface Span {
20-
addPropertyChangeHandler(): void;
21-
removePropertyChangeHandler(): void;
22-
}
17+
FormattedString.prototype.addPropertyChangeHandler = function(span: Span) {
18+
span.on(Observable.propertyChangeEvent, this.onPropertyChange, this);
19+
};
20+
FormattedString.prototype.removePropertyChangeHandler = function(span: Span) {
21+
span.off(Observable.propertyChangeEvent, this.onPropertyChange, this);
22+
};
23+
FormattedString.prototype.eachChild = function(callback: (child: ViewBase) => boolean): void {
24+
this.spans.forEach((v, i, arr) => callback(v));
2325
}
2426

25-
FormattedString.prototype.addPropertyChangeHandler = function() {}
26-
FormattedString.prototype.removePropertyChangeHandler = function() {}
27-
Span.prototype.addPropertyChangeHandler = function() {}
28-
Span.prototype.removePropertyChangeHandler = function() {}
29-
30-
3127
export const cssProperty = (target: Object, key: string | symbol) => {
3228
// property getter
3329
const getter = function() {

0 commit comments

Comments
 (0)