2
I’m needing to return a previous object from an object, that’s because I’m using this
test function.
Behold:
NodeList.prototype.style={
set background(a){
DefStyle("background",a,this)//aqui
},set backgroundColor(a){
DefStyle("backgroundColor",a,this/*não era isso que eu queria :/*/)//e aqui...
}
};
That one this
returns the object/property style
prototype NodeList
(I’m using querySelectorAll
for the test, it generates a Divs), but that was not the intention.
The this
currently return an object with setters background
and backgroundColor
! Example (without using setters):
{background:null,backgroundColor:null}
Is there any way legal return the parent object of the parent object of that object this
, come before prototype
(always know there don’t seem to be ways)?
Obs:
- I want to do something like
parentElement
, but withoutDOM
, usingobjetos
/propriedades
, as: Objeto={Huh:null,Propriedade:null};
Objeto.Propriedade.parent
, I wanted to returnObjeto
.
I read your question three times and I don’t understand what you’re trying to do. Your question is (or seems to be) something simple, but you express yourself in such a confused way that you cannot understand anything. The first suggestion is as to that name "relative". If the idea is to translate the term "Parent" of English, so you did wrong, because "Parent" is not "relative" in English. In English the term "Parent" It is a word referring to a person who is a father or mother. However, it is still hard to understand. I suggest you give more details about what you are trying to do with this.
– Victor Stafusa
Do you refer to elements of the DOM or do you want to know from which object another object has inherited?
– Sergio
@Victorstafusa I know that, but what I want to do is something like
parentElement
, only with objects/properties, in JS, bythis
on my prototype. :/– Klaider
@Sergio I mean the one
NodeList
! I want to pick up the relative object until such returnquerySelectorAll
with more Ivs. Note: Everything that returnsquerySelectorAll
saneprototype
ofNodeList
, and are something like arrays, although.– Klaider
Sorry for the delay, my mother sent me to sleep.......
– Klaider
Obey and honor your mother. Good sleep.
– durtto
@durtto And good morning, dss.
– Klaider
Good morning. Look at the answers, I think they got you a solution.
– durtto
@durtto The only problem is because the solutions have to do with
DOM
.– Klaider
I’m sorry but it’s still unclear to me. Do you want to write the
prototype
with a Seter/getter your? that allows you to write/read the style and also return the parent element an/Node element?– Sergio
I want to apply a style to several elements within a
NodeList
(querySelectorAll), but without looping in line, with the same face of the JS, to do some tests... as:document.querySelectorAll(".lF").style.huh=...
, and for that I need to take the objectparente
ofthis
inprototype
that I posed in the question.– Klaider