Comments (5)
Personally i dont think setting null and preserving chain is correct behaviuor.
Such
thing should be done thought removeAttr($name) or at least attr($name, "").
Thats simply because there is no (straightforward) way to determine what do you
expect when second param is null (it should be by default something which
simulates
null, but its not null).
But i can be wrong, does jQuery allows that ?
Original comment by [email protected]
on 2 Oct 2008 at 9:00
from phpquery.
I think jQuery allows chaining in such a case. It does not chain on the
attribute
but on the element from which the attribut has been deleted / remove or in this
case
set to null.
But there is no setting to null with jQuery. Just an Idea: Maybe setting an
attribute value to null should throw an exception for the sake of clarify.
Original comment by [email protected]
on 5 Oct 2008 at 10:04
from phpquery.
Test case :
<js>$('div#contenu_actualite').attr('id',null).find('div.bloc_arrondi_haut').att
r('class');</js>
display : "bloc_arrondi_haut" so chaining works
<js>$('div#contenu_actualite').attr('id',undefined).find('div.bloc_arrondi_haut'
).attr('class');</js>
get an error, so chaining doesn't work
Original comment by [email protected]
on 6 Oct 2008 at 10:23
from phpquery.
A little "hack" to get chaining work with null value is :
<php>
$myValue = null;
echo $myPhpQuery->find('#myId)->attr('myAttr',''.$myValue)->end()->html();
</php>
And it's working ;).
Original comment by [email protected]
on 13 Oct 2008 at 1:58
from phpquery.
As PHP doesnt support 'undefined' type, 'null' is used as equivalent.
In jQuery following code:
.attr('id',null)
will result in id='null'
In phpQuery it can be easly achived by:
->attr('id', 'null')
with same result.
Original comment by [email protected]
on 18 Oct 2008 at 9:00
- Changed state: WontFix
- Added labels: Component-phpQuery
from phpquery.
Related Issues (20)
- Unable to install using pear HOT 7
- pear repo packages.xml seems broken
- Wrong parsed HTML from HTML cleared by Tidy
- default: added to all HTML tags via Clone & PrependTo
- typo in line 517
- when program is utf-8,but remote page is gbk , the wrong has occur
- A PHP Error was encountered
- How to print the whole array of result without using foreach
- Notice (8): Undefined variable: hltml [phpQuery\DOMDocumentWrapper.php, line 389]
- GPL ?
- DOMDocument::importNode(): Cannot import: Node Type Not Supported
- Nested elements in script tag / create elements with jQuery
- Case-sensitive tag selectors HOT 3
- phpquery-onefile.php line 517
- Using multiple selectors return element list in wrong order
- Patch for /branches/dev/demo.php
- elements with dots "." in their id cannot be selected
- Getting Started Page
- How to use http-proxy for getBrowser & ajax requests? HOT 1
- your api docs have been hacked
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phpquery.