All --
I'm trying to solve a problem for which I think the solution will be
to *cheat*; but I don't mind doing so for this case. The background is:
Given an object constructor, and an instance
SampleObj = function() {
this.prop = 1;
}
obj = new SampleObj();
obj has one enumerable property: 'prop'; and several builtin,
non-enumerable properties as well: 'toString', 'hasOwnProperty ',
'propertyIsEnum erable', etc. If I redefined any of those, e.g:
SampleObj.proto type.toString = function() {return '[SampleObj]'};
then obj still has only one enumerable property; the redefinition of
toString doesn't affect its "DontEnum"-ness.
I'd like to be able to create such a property from JavaScript. In
particular, in older versions of Safari, some of those required properties
aren't implemented (hasOwnProperty , isPrototypeOf, propertyIsEnume rable,
& toLocaleString) . If I define them myself:
Object.prototyp e.toLocaleStrin g = Object.prototyp e.toString;
[etc.]
then they are enumerable, which causes problems for code like
for (var prop in obj) ...
I'll get a different set of enumerated properties in Safari than in (e.g.)
Mozilla; and have to specifically check for those that I defined myself,
to make code work appropriately on each browser. This gets tricky
(considering that the old Safari versions also failed to implement
toExponential, toFixed and toPrecision for Number objects).
The ability to set the DontEnum and ReadOnly attributes of object
properties would have been great; but (afaik) there is no way to do so. So
I'm looking for a "backdoor" in Safari that would allow this.
Help anyone?
Howard Jess
Nov 23 '05
16 4353
RobG wrote: Howard Jess wrote: var sel = document.create Element('select '); var opt = document.create Element('option '); sel.add(opt,nul l);
I thought the most widely supported method here was:
var sel = document.create Element('select '); sel.options[sel.options.len gth] = new Option(...);
Maybe that's what you do in your library...
Not quite; that was a very simple example. Given:
function moveOption(from Sel,toSel,fromI ndex,toIndex) {
var opt = fromSel.options[fromIndex];
if (opt != null) // yes, this is an explicit test
toSel.add(opt,t oIndex);
}
According to the W3C spec, there's no reason this should
not work; but you may find it problematic in some browsers.
The library makes it work as expected.
[Caveat: I'm posting from home; this is from memory and untested.]
hj
hj wrote: Not quite; that was a very simple example. Given:
function moveOption(from Sel,toSel,fromI ndex,toIndex) { var opt = fromSel.options[fromIndex]; if (opt != null) // yes, this is an explicit test toSel.add(opt,t oIndex); }
Um ... as I was saying ...
function moveOption(from Sel,toSel,fromI ndex,toIndex) {
var opt = fromSel.options[fromIndex];
if (opt != null) // yes, this is an explicit test
toSel.add(opt,t oSel.options[toIndex]);
}
hj
VK wrote: RobG wrote:
I suppose suggesting Firefox is of no use? ;-)
Or if the Aqua-style is too precious to you ;-) you may consider Gecko Camino: <http://www.caminobrows er.org/>
I've tried Camino, but it's only at version 0.8.4 so while OK for home
use can't really be recommended to a corporate client.
Ooops!! Just checked Mozilla.org, Camino has now hit 1.0b1 - seems they
even got tabs to left-justify!! Safary 1.x - 2.0 is a complete junk as browser. So is the Konqueror used as the base for it.
Dunno, I find Safari fine for general web surfing. I like many of the
features, though its support for JavaScript and DOM is disappointing -
but I haven't tried the latest version yet. I'm trying to get OS X 10.4
on eBay but keep getting sniped!
[...]
--
Rob
RobG wrote: I've tried Camino, but it's only at version 0.8.4 so while OK for home use can't really be recommended to a corporate client.
I have seen too many good 0.x versions of software to find this argument
justified.
PointedEars
Thomas 'PointedEars' Lahn wrote: RobG wrote:
I've tried Camino, but it's only at version 0.8.4 so while OK for home use can't really be recommended to a corporate client.
I have seen too many good 0.x versions of software to find this argument justified.
I have deal with too many officious system adminstrators not to consider
it. ;-)
Anyhow, it seems 1.0 is (nearly) here.
--
Rob
RobG wrote: Dunno, I find Safari fine for general web surfing.
I did not say "It's a bad HTML 4.0 renderer". I said "It's a bad
browser". ;-)
Year 2005 these are very different kinds.
hj wrote: hj wrote: Not quite; that was a very simple example. Given:
function moveOption(from Sel,toSel,fromI ndex,toIndex) { var opt = fromSel.options[fromIndex]; if (opt != null) // yes, this is an explicit test toSel.add(opt,t oIndex); }
Um ... as I was saying ...
function moveOption(from Sel,toSel,fromI ndex,toIndex) { var opt = fromSel.options[fromIndex]; if (opt != null) // yes, this is an explicit test toSel.add(opt,t oSel.options[toIndex]); }
or even (accounting for both per-spec and IE-specific behavior):
function moveOption(from Sel,toSel,fromI ndex,toIndex) {
var opt = fromSel.options[fromIndex];
if (opt != null) // yes, this is an explicit test
try {toSel.add(opt, toSel.options[toIndex])} catch(err) {
toSel.add(opt,t oIndex);
}
}
hj This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Erik Max Francis |
last post by:
I've come across a limitation in unpickling certain types of complex
data structures which involve instances that override __hash__, and was
wondering if it was known (basic searches didn't seem to come up with
anything similar) and if there is a workaround for it short of
restructuring the data structures in question.
The fundamental issue rests with defining classes which override __cmp__
and __hash__ in order to be used as keys in...
|
by: Dotnetified |
last post by:
Reposting after about 2 weeks of no response ... thanks if you can help...
----------------------------------------------------------------------------
--------------
To anyone who thinks they know it all: ;)
We recently upgraded our MSDN Version of VS.NET 2002 to VS.NET 2003...
Things are all working well, except we've run across a new bug or issue
since our adopting of the new package.
|
by: Robert Mark Bram |
last post by:
Howdy all!
When do I call something a property and when do I call something an
attribute?
It has me a little confused at the moment!
Any advice would be most appreciated!
Rob
|
by: Robin Becker |
last post by:
Is there a way to override a data property in the instance? Do I need to create
another class with the property changed?
--
Robin Becker
|
by: David N |
last post by:
All,
I created a control that have the following property defined:
private bool autoSearch
My control is compiled and created fine. But, after adding the control to
my form, I noticed the following problems:
| |
by: Harry F. Harrison |
last post by:
I get 2 compile errors on assembly attributes after creating a custom
attribute. If I comment out the attribute, the errors go away. I don't get
it because my attribute specifies class usage, not assembly usage.
Assembly attribute 'System.Runtime.InteropServices.GuidAttribute' is not
valid: Assembly custom attribute
'System.Runtime.InteropServices.GuidAttribute' was specified multiple times
with different values
Attribute...
|
by: Sam Kong |
last post by:
Hello!
I got recently intrigued with JavaScript's prototype-based
object-orientation.
However, I still don't understand the mechanism clearly.
What's the difference between the following two?
(1)
|
by: =?Utf-8?B?Z2FkeWE=?= |
last post by:
I use one of 2 arrays dependent on the country.
Rather than say:
if exchangeID = 1 then
dim myPlaceBets() as As UK.exchange.PlaceBets
many statements
myPlaceBetsReq.bets = myPlaceBets
else
dim myPlaceBets() As AU.exchange.PlaceBets
many statements
|
by: Rafe |
last post by:
Hi,
I've encountered a problem which is making debugging less obvious than
it should be. The @property decorator doesn't always raise exceptions.
It seems like it is bound to the class but ignored when called. I can
see the attribute using dir(self.__class__) on an instance, but when
called, python enters __getattr__. If I correct the bug, the attribute
calls work as expected and do not call __getattr__.
I can't seem to make a simple...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |