Skip to content

Commit 751b132

Browse files
author
Ben Grynhaus
committed
[core] fix style set by the wrapper component being passed down to React component
1 parent 51e58db commit 751b132

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

libs/core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "../../node_modules/ng-packagr/package.schema.json",
33
"name": "@angular-react/core",
4-
"version": "0.2.2",
4+
"version": "0.2.3",
55
"ngPackage": {
66
"lib": {
77
"languageLevel": [

libs/core/src/components/wrapper-component.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
OnChanges,
1111
SimpleChanges,
1212
HostBinding,
13-
Input
13+
Input,
1414
} from '@angular/core';
1515
import toStyle from 'css-to-style';
1616

@@ -26,7 +26,8 @@ const forbiddenAttributesAsProps: ReadonlyArray<AttributeNameAlternative> = [
2626
['style', 'rStyle'],
2727
];
2828

29-
const ignoredAttributeMatchers = [/^_?ng-?.*/];
29+
// Forbidden attributes are still ignored, since they may be set from the wrapper components themselves (forbidden is only applied for users of the wrapper components)
30+
const ignoredAttributeMatchers = [/^_?ng-?.*/, /^style$/, /^class$/];
3031

3132
const ngClassRegExp = /^ng-/;
3233

@@ -102,7 +103,7 @@ export abstract class ReactWrapperComponent<TProps extends {}> implements AfterV
102103
public readonly elementRef: ElementRef,
103104
private readonly changeDetectorRef: ChangeDetectorRef,
104105
private readonly setHostDisplay: boolean = false
105-
) { }
106+
) {}
106107

107108
ngAfterViewInit() {
108109
this._passAttributesAsProps();
@@ -197,7 +198,7 @@ export abstract class ReactWrapperComponent<TProps extends {}> implements AfterV
197198
throw new Error(
198199
`[${(this.elementRef
199200
.nativeElement as HTMLElement).tagName.toLowerCase()}] React wrapper components cannot have the '${
200-
attr.name
201+
attr.name
201202
}' attribute set. Use the following alternative: ${alternativeAttrName || ''}`
202203
);
203204
}

0 commit comments

Comments
 (0)