Comments (2)
This behavior is correct: childNodes
is a "live" NodeList, and changing the children is reflected immediately in the list. Which also means the current i
now points to what would have been the next child, thus when the loop advances it skips an item.
Javascript implements it that way. Does PHP really want to be different about it?
https://jsfiddle.net/54hoLzqv/
(keep in mind that it's the console output which shows items 1,2,3, while the document had 3 removed and so ends up with items 1,2,4)
Same for attributes, which is also a live NodeList.
Obligatory "this behavior has existed for a really long time so is there a good enough reason to change it now?"
from php-src.
The example is badly chosen, I've corrected the example. Then you can see that the iteration stops despite the list being needing to be live.
Obligatory "this behavior has existed for a really long time so is there a good enough reason to change it now?"
Obligatory "we kind of worked around that issue": https://wiki.php.net/rfc/opt_in_dom_spec_compliance
from php-src.
Related Issues (20)
- Compiling from source, no extensions found HOT 3
- Consider removing autogenerated files from tarballs HOT 1
- hex2bin() returning a base64 encoded string HOT 9
- Member access within null pointer of type 'ps_files' in ext/session/mod_files.c HOT 1
- Unexpected Results with PHP8 date_diff for Different Timezones HOT 3
- Incorrect PHP_STREAM_OPTION_CHECK_LIVENESS case in ext/openssl/xp_ssl.c - causing use of dead socket HOT 1
- PECL list-upgrade doesn't seems to respect php versions HOT 4
- Improve deprecation message for implicit nullable parameters HOT 3
- number_format() changed undocumented behaviour since PHP 8.3.0 HOT 5
- do_operation ZEND_BOOL_NOT not invoked HOT 1
- `preg_match` require match HOT 1
- auto_prepend_file register_shutdown_function TypeError fatal error because function not hoisted HOT 2
- [Chore] Officially support musl the same way glibc is supported HOT 11
- php.ini INI_SYSTEM: local value of "sys_temp_dir" does not overide master value and can bypass "open_basedir" (not a security issue FMPOV)
- Signed integer overflow in ext/date/lib/unixtime2tm.c
- ARM64 + BSD15 - CGI PHP - 502 Bad Gateway error HOT 5
- stream_select fails on blocking sockets except for incoming connections HOT 2
- FR: allow use class constant interpolation in strings HOT 1
- === Total 1 memory leaks detected === zend_mm_heap corrupted Segmentation fault HOT 2
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 php-src.