How to assign HTML entities in Polymer element definition?

后端 未结 1 722

Alternative question version: How to prevent HTML entities from being escaped, when added in the Polymer element definition?

So assume this simplifi

1条回答
  •  离开以前
    2020-12-04 02:56

    There are a couple of ways to do this:

    • Custom filters (not documented yet)

      encodeEntities: function(value) {
        var div = document.createElement('div');
        div.innerHTML = this.shownVal;
        return div.innerHTML;
       }
      
    • Use automatic node finding and set the .innerHTML of some container.

      this.$.container.innerHTML = this.shownVal;
      

    Demo showing both of these: http://jsbin.com/uDAfOXIK/2/edit

    0 讨论(0)
提交回复
热议问题