William
William

Reputation: 3395

Rangy.js - createClassApplier with Multiple Classes

I am trying to create a class applier that would wrap the selection in the following element:

<code class="mainClass selector1 selector2">Selected Content</code>

I am doing the following:

var Applier = rangy.createClassApplier("mainClass",
{
    elementTagName: "code",
    elementProperties:
    {
        className: [ "selector1", "selector2" ]
    }
});

Applier.toggleSelection();

This yields the following:

<code class="mainClass selector1,selector2">Selected Content</code>

What is the syntax to create the applier so that it does what I am trying to do?

Upvotes: 5

Views: 888

Answers (1)

William
William

Reputation: 3395

It seems like this was not implemented (see here). To fix it, change line 69 in range.classApplied to this:

if (typeof el.classList == "object" && typeof className == "object")

Upvotes: 0

Related Questions