The method getChildCount
has been added to get the number of children a WuiDom may have.
Simpler and faster than going through getChildren().length
.
Updated events
to 1.1.0
WuiDom finally get released under WizUI and have its package.json file to reach even more build systems.
Updated Wizcorp/events
to v0.1.3
The method replaceClassNames
allows having empty strings without crashing.
Improvement has been made on the internal method _destroyChildren
which should make
the call of clearContent
and destroy
faster to execute.
Using now the API of classList
from DOMTokenList for every class name operation.
We are using a shim to make sure to be compatible with older browser.
:warning: toggleClassNames
is now deprecated in favor of toggleClassName
The toggleClassNames
method was partially broken.
When second arguments, shouldAdd
, is undefined
it will trigger a real toggle, which is now fixed.
The toggleDisplay
now returns the status of the display.
Also fixed a bug where passing an undefined
variable will always toggle on.
A new method getComputedStyles
allows to retrieve multiple computed style properties in one call.
The method isVisible
can now go up the tree of ancestor if it's really visible or not.
assign
method is now deprecated.
Since v0.2.0 you can assign from the constructor.
It's time to move on.
The use of setting a function and timer for setText
and setHtml
disappeared long time ago.
Perhaps because of the arrival of Tomes and bindToTome
.
This is why from now on, those 2 methods will do simply what they have to do.
query
and queryAll
has been removed.
Those was returning a Dom which seems useless since we wanna work WuiDoms
A new method called toggleClassNames
has been added for the good of avoiding silly if/else logic.
Check the API in the readme for more info.
removeChild
would accept only string as an ID, it is now more open to numbers.insertChildBefore
were crashing when the second argument was not provided.replaceClassNames
were keeping adding class names from theaddList
argument even if already present.
The emission of the events 'show'
and 'hide'
will now happened when the actions are done.
Added the method getWuiName
to get the name given to the WuiDom.
Added the method toggleDisplay
to be able to switch visibility.
The method can also receive a boolean as argument to avoid complicated code for a hide/show logic.
if (shouldDisplay) {
myDiv.show();
} else {
myDiv.hide();
}
Now becomes:
myDiv.toggleDisplay(shouldDisplay);
show
and hide
methods were used to be able to pass data through the event.
This is no longer the case.
For a better support of both and for the upcoming desktop browsers supporting both we no longer choose one or the other when requiring WuiDom, but make the right choice when getting the events instead. This possibly mean that a user should be able to switch between using his finger or his mouse.
The getComputedCSSStyle
were using getPropertyValue
which is not supported by all browsers.
Using directly getComputedStyle
instead, which return the same as the cssText
wanted from getComputedCSSStyle
.
In #replaceClassNames
when a class name was present from the delList
and the addList
it wouldn't be added.
Wizcorp/events
is now v0.1.2
Added a way to get access to the children with two new methods
getChildren
which will return an array of WuiDom in the order they are supposed to be.getChild
take a string as argument and return the wanted WuiDom
To use the latest, just need to add a name of the WuiDom when using createChild
or appendChild
.
And because we are evil, we can now clear the content of a WuiDom, which will empty the text or html of this one, and recursively destroys all its children along with it.
What does it really means? Well, you can now pass the argument you were giving to this method to the constructor.
var myElement = new WuiDom('div', { className: 'box' };
Or the following for inheritance.
var inherit = require('inherit');
var WuiDom = require('WuiDom');
var buttonBehavior = require('wuiButtonBehavior');
function MyButton(caption) {
WuiDom.call(this, 'div', { className: 'MyButton', text: caption });
buttonBehavior(this);
}
inherit(MyButton, WuiDom);
module.exports = MyButton;
The method createElement
wasn't really use because of it's redundancy with the creation of a new WuiDom.
And since we can pass argument to the constructor of WuiDom it has no more reason to exist.
First version