Re: RegExp for hyphen to camelCase?





Michael Winter wrote:

On 21/07/2005 14:10, Martin Honnen wrote:

so in Mozilla and Opera you can do
  return window.getComputedStyle(el, '')[prop]


You could but the global object has never been defined as an instance of the AbstractView interface. I would use the slightly longer, but better defined route through the document object:

document.defaultView.getComputedStyle(...)

Right, I was mainly following Rob's code and only changing the part after the getComputedStyle. I have myself pointed out that document.defaultView and window don't have to be the same as far as the W3C DOM says but as far as Mozilla goes Brendan Eich himself said the current behaviour is not going to be changed:
<http://groups-beta.google.com/group/netscape.public.mozilla.dom/msg/aa219bf41334c22e?hl=en&;>
And the current WHAT WG drafts also try to ensure that the current praxis that browsers implement document.defaultView as the window object becomes standardized:
<http://www.whatwg.org/specs/web-apps/current-work/#documentwindow>
so it seems pretty safe to do window.getComputedStyle.



Neither Safari nor Konqueror support the getComputedStyle method. Though it exists as a property of the defaultView object in Konqueror, it always returns null.

Ouch, one more case for not only checking for the existance of a method in the DOM but to check for the result too.


--

	Martin Honnen
	http://JavaScript.FAQTs.com/
.



Relevant Pages

  • Re: If...else statement
    ... but could not find the window object in DOM ... DOM standard has ever specified that the ECMAScript global object (or ... as they are the same object in a browser object model) ...
    (microsoft.public.scripting.jscript)
  • Re: Dynamic select lists using optgroups again - without frameworks
    ... convertible to boolean `true' does not follow necessarily that the property ... implement the EventTarget interface of W3C DOM Level 2 Events. ... Window object instead. ... by numerous frameworks and scripts, ...
    (comp.lang.javascript)
  • Re: Dynamic select lists using optgroups again - without frameworks
    ... convertible to boolean `true' does not follow necessarily that the property ... also supporting several event listeners ... Window object instead. ... You will observe that you also don't need any DOM branching for this. ...
    (comp.lang.javascript)
  • Re: Accesing an IFrame from an internal element
    ... More likely because he knows how the DOM works. ... nor the element has a reference to a window object. ... That's a property on the DOM element of the iframe in the parent document, ...
    (comp.lang.javascript)