adobe / adobe/react-webcomponent

DOM content retrieved by @byContent still renders with the react component mounted

オープン
#9 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
JavaScript
スター
104
フォーク
20
PR マージ指標
30日以内にマージされた PR はありません

説明

### Expected Behaviour
As stated in the documentation:

> The DOM content will be moved when the React component is mounted. And, the content will be put back in its original location if the React component is later unmounted.

### Actual Behaviour
After some tests, if the property holding the content (inside the react component) is not used, even if the react component is still mounted, the DOM content is still put back in its original location.

#### Sample Code that illustrates the problem
###### React component:
```javascript
import React from 'react';
import PropTypes from 'prop-types';

const Example = ({
// products,
title,
content,
}) => (


{ title === 'yepe' && content }
{ title !== 'yepe' &&

Not the title I expected

}

);

Example.propTypes = {
// products: PropTypes.arrayOf(PropTypes.object).isRequired,
title: PropTypes.string,
content: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),
PropTypes.node,
]).isRequired,
};

Example.defaultProps = {
title: 'no',
};

export default Example;
```

###### React container:
```javascript
import {
DOMModel,
byAttrVal,
byContent,
} from '@adobe/react-webcomponent';
import { connect } from 'react-redux';
import Example from '../example/example';
import { action } from 'actions';

const mapStateToProps = state => ({
products: state.products,
});

const ReduxedExample = connect(
mapStateToProps,
{ action },
)(Example);

class ExampleModel extends DOMModel {
@byAttrVal('title') title;

@byContent('.content') content;
}

// Register web component "example-component"
// using above Model
});
```

###### Html example:
```html


This is the correct title!

```

![2018-12-19 13_15_51-example template localhost](https://user-images.githubusercontent.com/7437402/50219752-7b47fc80-0390-11e9-8cef-00b8fbd53726.png)

###### Other html example:
```html


This is the correct title!

```

![2018-12-19 13_16_42-example template localhost](https://user-images.githubusercontent.com/7437402/50219786-8a2eaf00-0390-11e9-8bd5-b3c16f232b67.png)

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

まず、issue で説明されている DOMModel と @byContent の動作を追跡します。入口として ExampleModel の再現例とその React コンポーネントを使用してください。両方の title 値について、コンテンツがいつ移動または復元されるかを確認し、その後、コンポーネントがコンテンツを条件付きでレンダリングしない場合でも、マウントされたコンテンツがその場に残ることを示す回帰テストを追加してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
javascript, react
領域
frontend
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。