                 
                 // remove all styles for the specified range here!
                 
-                let finalRange = NSRange(location: range.location, length: attributedString.length)
-                strongSelf.applyStyles(from: attributedString, spanning: finalRange)
+                strongSelf.applyStyles(from: attributedString, to: range.location)
             }
         }
         

                return
            }
            
            applyStyle(underlineStyle: style, spanning: range)
        }
        
        /// Applies the underline style spanning the specified range to the DOM.
        ///
        /// - Parameters:
        ///     - style: the style of the underline.
        ///     - range: the range the attribute is spanning.
        ///
        private func applyStyle(underlineStyle style: NSUnderlineStyle, spanning range: NSRange) {
            
            switch (style) {
            case .StyleSingle:

extension Libxml2 {
    
    /// This class takes care of providing an interface for all DOM interaction.
    /// It also takes care of queueing all mutating requests made to the DOM.
    ///
    class DocumentObjectModel {
        
