Opened 7 years ago

Closed 6 years ago

#9981 closed New Feature (fixed)

Implement fragment#filter

Reported by: Piotrek Koszuliński Owned by: Piotrek Koszuliński
Priority: Normal Milestone: CKEditor 4.1 RC
Component: Core : Parser Version:
Keywords: Cc:

Description

Currently it's not possible to apply more than one filter to doc fragment. Filter can only be applied when fragment is being written to HTML. That reduces flexibility needed in tickets like #8784 and #9829.

Change History (6)

comment:1 Changed 7 years ago by Piotrek Koszuliński

Owner: set to Piotrek Koszuliński
Status: newassigned

comment:2 Changed 6 years ago by Piotrek Koszuliński

Status: assignedreview

Pushed t/9981 on dev and tests.

comment:3 Changed 6 years ago by Frederico Caldeira Knabben

Status: reviewreview_failed

There is a change on a previously existing TC which looks wrong. It's inside dt/core/htmlparser/filter.html, in 'test elementNames rules' at line 150,

The element name rule [ 'foo', 'bar' ] must have a full match. This means that <foo> becomes <bar>, but <foofoo> must stay intact. Actually both the old and the new tests seem to be wrong (both <barfoo> and <barbar>).

If a partial match would be ever required, a regex should be used, not a string.

comment:4 Changed 6 years ago by Piotrek Koszuliński

Status: review_failedreview

Unfortunately this was broken from the very beginning. My changes in this branch just fixed the filter so it applies filter as long as name is changed - exactly like for elementNames.

When writing tests for #9972 I also found this weird behaviour that string is used as a replace() pattern, so it doesn't mean full match. Initially I also found this completely wrong. But then I checked if there's a chance to fix it without affecting performance and I think that it'd better to leave this simple mechanism. First element in array is used as a replace pattern (replace() accepts string and regexp), second element as replacement. That's all.

What's more - our code doesn't use string pattern (only one usage in htmlDataProcessor, but rather safe). Instead, it uses regexp correctly.

So, I'm to leave this as expected behaviour. This is how it worked, this is fast and the only wrong thing is that it wasn't documented so it may be a little confusing.

Last edited 6 years ago by Piotrek Koszuliński (previous) (diff)

comment:5 Changed 6 years ago by Frederico Caldeira Knabben

Status: reviewreview_passed

comment:6 Changed 6 years ago by Piotrek Koszuliński

Resolution: fixed
Status: review_passedclosed

Commited into major with git:6c8624e.

Note: See TracTickets for help on using tickets.
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy