Migrated some code from into DomElement to BaseElement