| 225 | // Check element matches the style itself. |
| 226 | if ( this.checkElementMatch( element, fullMatch ) ) |
| 227 | return true; |
| 228 | |
| 229 | // Check if the element matches the style overrides. |
| 230 | var override = getOverrides( this )[ element.getName() ] ; |
| 231 | if ( override ) |
| 232 | { |
| 233 | // If no attributes have been defined, remove the element. |
| 234 | if ( !( attribs = override.attributes ) ) |
| 235 | return true; |
| 236 | |
| 237 | for ( var i = 0 ; i < attribs.length ; i++ ) |
| 238 | { |
| 239 | attName = attribs[i][0]; |
| 240 | var actualAttrValue = element.getAttribute( attName ); |
| 241 | if ( actualAttrValue ) |
| 242 | { |
| 243 | var attValue = attribs[i][1]; |
| 244 | |
| 245 | // Remove the attribute if: |
| 246 | // - The override definition value is null; |
| 247 | // - The override definition value is a string that |
| 248 | // matches the attribute value exactly. |
| 249 | // - The override definition value is a regex that |
| 250 | // has matches in the attribute value. |
| 251 | if ( attValue === null || |
| 252 | ( typeof attValue == 'string' && actualAttrValue == attValue ) || |
| 253 | attValue.test( actualAttrValue ) ) |
| 254 | return true; |
| 255 | } |
| 256 | } |
| 257 | } |
| 258 | return false; |
| 259 | }, |
| 260 | |
| 261 | // Check if the element matches the current style definition. |
| 262 | checkElementMatch : function( element, fullMatch ) |
| 263 | { |
269 | | // Check if the element can be somehow overriden. |
270 | | var override = getOverrides( this )[ element.getName() ] ; |
271 | | if ( override ) |
272 | | { |
273 | | // If no attributes have been defined, remove the element. |
274 | | if ( !( attribs = override.attributes ) ) |
275 | | return true; |
276 | | |
277 | | for ( var i = 0 ; i < attribs.length ; i++ ) |
278 | | { |
279 | | attName = attribs[i][0]; |
280 | | var actualAttrValue = element.getAttribute( attName ); |
281 | | if ( actualAttrValue ) |
282 | | { |
283 | | var attValue = attribs[i][1]; |
284 | | |
285 | | // Remove the attribute if: |
286 | | // - The override definition value is null; |
287 | | // - The override definition value is a string that |
288 | | // matches the attribute value exactly. |
289 | | // - The override definition value is a regex that |
290 | | // has matches in the attribute value. |
291 | | if ( attValue === null || |
292 | | ( typeof attValue == 'string' && actualAttrValue == attValue ) || |
293 | | attValue.test( actualAttrValue ) ) |
294 | | return true; |
295 | | } |
296 | | } |
297 | | } |