Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renovation: provide custom sizes from styles #12580

Merged
merged 1 commit into from
Apr 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions js/renovation/preact-wrapper/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import DOMComponent from '../../core/dom_component';
import * as Preact from 'preact';
import { extend } from '../../core/utils/extend';
import { getInnerActionName } from './utils';
import { isEmpty } from '../../core/utils/string';

export default class PreactWrapper extends DOMComponent {
getInstance() {
Expand Down Expand Up @@ -30,6 +31,7 @@ export default class PreactWrapper extends DOMComponent {
getProps(isFirstRender) {
const options = extend({}, this.option());
const attributes = this.$element()[0].attributes;
const { width, height } = this.$element()[0].style;

if(isFirstRender) {
options.elementAttr = extend(Object.keys(attributes).reduce((a, key) => {
Expand All @@ -50,6 +52,12 @@ export default class PreactWrapper extends DOMComponent {
.filter(name => name.indexOf('dx-') < 0);
}
}
if(!isEmpty(width)) {
options.width = width;
}
if(!isEmpty(height)) {
options.height = height;
}

return options;
}
Expand Down
3 changes: 1 addition & 2 deletions testing/tests/Renovation/button.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,7 @@ QUnit.module('widget sizing render', {}, () => {
const instance = $element.Button('instance');

assert.strictEqual(instance.option('width'), undefined);
// TODO
// assert.strictEqual($element.outerWidth(), 300, 'outer width of the element must be equal to custom width');
assert.strictEqual($element.outerWidth(), 300, 'outer width of the element must be equal to custom width');
});

QUnit.test('change width', function(assert) {
Expand Down