Add "Noah's Ark Clause", three per family, to the list of active formatting elements
When adding new elements to the list, if there are already three same elements present, then remove the oldest one before inserting the new.
This commit is contained in:
@@ -45,6 +45,21 @@
|
||||
|
||||
- (void)addElement:(HTMLElement *)element
|
||||
{
|
||||
NSUInteger existing = 0;
|
||||
for (HTMLElement *node in _list.reverseObjectEnumerator.allObjects) {
|
||||
if ([node isEqual:[HTMLMarker marker]]) {
|
||||
break;
|
||||
}
|
||||
if (node.namespace == element.namespace &&
|
||||
[node.tagName isEqualToString:element.tagName] &&
|
||||
[node.attributes isEqualTo:element.attributes]) {
|
||||
existing++;
|
||||
}
|
||||
if (existing == 3) {
|
||||
[_list removeObject:node];
|
||||
break;
|
||||
}
|
||||
}
|
||||
[_list addObject:element];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user