KyleAMathews / element-resize-event

Library to make it easy to listen for element resize events
http://kyleamathews.github.io/element-resize-event/
MIT License
175 stars 44 forks source link

Giving CSS declaration more priority to ensure it always work #21

Closed runningdemo closed 6 years ago

runningdemo commented 7 years ago

I encounter a bug when making a third part widget. In this widget, I have to use cleanslate to write more defensive CSS to protect my widget's style from been overwritten by the client's CSS. Take a CSS reset rule from cleanslate for example:

.cleanslate div {
    position:static !important;
}

This CSS rule will absolutly win element.style.position = 'relative' in CSS specificity and break the way 'element-resize-event' works. So I made this pull request to fix this issue.

Love to hear your thought.

JLarky commented 7 years ago

@liaa you can still do something like

.cleanslate div.myElementClass {
    position:relative !important;
}

and just myElementClass to the div you are tying to add element-resize-event since it has more specificity than original widget css it will solve the issue you are having

runningdemo commented 7 years ago

@JLarky You are right partially. The method you offer can ensure the div I am trying to add element-resize-event to have position: relative. But can't ensure the element created by element-resize-event have expected CSS style. Take a look at this file.

JLarky commented 7 years ago

@liaa yes, but that doesn't mean that you can't create similar css for it .cleanslate .myElementClass object {} and I was under impression that cleanslate was only working with divs, not object

runningdemo commented 7 years ago

@JLarky Thank you for your reply. I think your solution works. FYI: Cleanslate sure have overwritten the object style.

eaglus commented 6 years ago

Does anybody still needs this PR? I think, it is very specific use-case, and we don't need it here.