Search code examples
javascriptrangy

elementProperties of Rangy doesn't work


I'm using Rangy 1.3 TextRange in order to find text in a div and wrap it with a span. I want to add more attributes to the span by adding the option elementProperties but the attributes aren't added at all.

var applier = rangy.createCssClassApplier(
                 "result", 
                 { 
                    elementProperties: {
                     'data-value': 1
                    }
                 } 
              );

I'm using Rangy 1.3 and testing it on Chromium.


Solution

  • elementProperties is for setting properties on elements rather than attributes. I have recently added elementAttributes as well (but not yet documented it), so you could use that instead for data attributes. The latest 1.3 release of Rangy has it.