File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed
Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,22 @@ public function setAttributes(array $attributes)
9898 }
9999 }
100100
101+ /**
102+ * Removes the attributes specified.
103+ *
104+ * @param array $attributes An array containing the names of the attributes to remove.
105+ * @return void
106+ */
107+ public function removeAttributes (array $ attributes )
108+ {
109+ foreach ($ attributes as $ name ) {
110+ $ name = strtolower ($ name );
111+ if (isset ($ this ->attributes [$ name ])) {
112+ unset($ this ->attributes [$ name ]);
113+ }
114+ }
115+ }
116+
101117 /**
102118 * Provides access to the component attributes via properties.
103119 *
Original file line number Diff line number Diff line change @@ -197,6 +197,20 @@ public function testComponentSetAttributes()
197197 $ this ->assertTrue ($ result === $ expectedResult );
198198 }
199199
200+ /**
201+ *
202+ */
203+ public function testComponentRemoveAttributes ()
204+ {
205+
206+ $ component = new \IvoPetkov \HTMLServerComponent ();
207+ $ component ->setAttributes (['aTTR1 ' => 'value1 ' , 'attr2 ' => 'value2 ' , 'attr3 ' => 'value3 ' ]);
208+ $ component ->removeAttributes (['attr1 ' , 'Attr3 ' ]);
209+ $ result = (string ) $ component ;
210+ $ expectedResult = '<component attr2="value2"></component> ' ;
211+ $ this ->assertTrue ($ result === $ expectedResult );
212+ }
213+
200214 /**
201215 *
202216 */
You can’t perform that action at this time.
0 commit comments