Blame view

src/Slot/Slot.js 628 Bytes
3a3ecabe   Imshann   init
1
  class Slot {
3a3ecabe   Imshann   init
2
3
  
      useModules = ["$compile"];
ddd373d9   Imshann   优化Card组件
4
5
6
7
8
      
      componentDidUpdate(prevProps) {
          if(prevProps.content !== this.props.content) {
          	if (newVal !== undefined) {
                  if (/<[^>]+>/.test(newVal)) {
3a3ecabe   Imshann   init
9
                      $element.replaceWith(
ddd373d9   Imshann   优化Card组件
10
                          $compile(newVal)(
3a3ecabe   Imshann   init
11
12
13
14
                              $scope.context ? $scope.context : $scope
                          )
                      );
                  } else {
ddd373d9   Imshann   优化Card组件
15
                      $element.text(newVal);
3a3ecabe   Imshann   init
16
17
                  }
              }
ddd373d9   Imshann   优化Card组件
18
          }
3a3ecabe   Imshann   init
19
20
      }
  }
ddd373d9   Imshann   优化Card组件
21
22
23
24
25
  
  Slot.propTypes = {
      content: PropTypes.string,
      context: PropTypes.object,
  };